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: [email protected]
Reporter: [email protected]
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.