You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2013/05/14 14:51:35 UTC
[Bug 54967] New: NullPointerException when updating a zip file that
has duplicate entries
https://issues.apache.org/bugzilla/show_bug.cgi?id=54967
Bug ID: 54967
Summary: NullPointerException when updating a zip file that has
duplicate entries
Product: Ant
Version: 1.9.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P2
Component: Core tasks
Assignee: notifications@ant.apache.org
Reporter: arussell@thrupoint.com
Classification: Unclassified
When updating an existing zip file that has duplicate entries, the zip task
throws a NullPointerException. This simple script reproduces the problem:
<?xml version="1.0"?>
<project name="testzip" default="testzip">
<target name="testzip">
<delete dir="testfiles"/>
<delete file="test.zip"/>
<mkdir dir="testfiles"/>
<echo file="testfiles/test.txt">This is a test file</echo>
<zip destfile="test.zip" basedir="testfiles">
<fileset dir="testfiles"/>
</zip>
<zip destfile="test.zip" update="true">
<fileset dir="${basedir}" includes="build.xml"/>
</zip>
</target>
</project>
Output:
Buildfile: /home/arussell/dev/testzip/build.xml
testzip:
[delete] Deleting directory /home/arussell/dev/testzip/testfiles
[delete] Deleting: /home/arussell/dev/testzip/test.zip
[mkdir] Created dir: /home/arussell/dev/testzip/testfiles
[zip] Building zip: /home/arussell/dev/testzip/test.zip
[zip] Updating zip: /home/arussell/dev/testzip/test.zip
BUILD FAILED
/home/arussell/dev/testzip/build.xml:12: java.lang.NullPointerException
at org.apache.tools.ant.taskdefs.Zip.zipFile(Zip.java:1827)
at org.apache.tools.ant.taskdefs.Zip.zipFile(Zip.java:1856)
at org.apache.tools.ant.taskdefs.Zip.addResource(Zip.java:1031)
at org.apache.tools.ant.taskdefs.Zip.addResources(Zip.java:953)
at org.apache.tools.ant.taskdefs.Zip.executeMain(Zip.java:702)
at org.apache.tools.ant.taskdefs.Zip.execute(Zip.java:568)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at
org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.Main.runBuild(Main.java:851)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Total time: 0 seconds
After a bit of digging, it seems that that this problem is related to the Zip64
support added in Ant 1.9.0. When I built a version of Ant with zip64Mode in
ZipOutputStream set to Zip64Mode.Never the problem went away.
It seems that the ZipEntry.equals method is concluding that objects are
different when they should be the same. This is down to the values of the
extra fields being different.
Anyway, I have only found this to cause a problem in build scripts that are
erroneously adding duplicate entries to zip files so adding
'duplicate="preserve"' is the simple workaround.
Thanks
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 54967] NullPointerException when updating a zip file that has
duplicate entries
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54967
--- Comment #2 from Stefan Bodewig <bo...@apache.org> ---
Just a quick status update: https://issues.apache.org/jira/browse/COMPRESS-227
A quick fix is to simply ignore existing duplicate entries, everything that
tried to preserve all duplicates will need an API change to ZipFile. I'll
discuss the options on the dev list.
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 54967] NullPointerException when updating a zip file that has
duplicate entries
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54967
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |1.9.2
--- Comment #3 from Stefan Bodewig <bo...@apache.org> ---
the NPE itself has been fixed in Ant 1.9.2
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 54967] NullPointerException when updating a zip file that has
duplicate entries
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54967
Antoine Levy-Lambert <an...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Version|1.9.0 |1.9.1
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 54967] NullPointerException when updating a zip file that has
duplicate entries
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54967
--- Comment #1 from Stefan Bodewig <bo...@apache.org> ---
I can confirm the bug. The problem seems to be ZipFile.getInputStream
returning null when asked for the stream of a duplicate entry. Off the top of
my head I don't know a quick fix since ZipFile hashes entries by name - I'm
looking into it.
--
You are receiving this mail because:
You are the assignee for the bug.