Hi all,
after a long time a small contribution again :-)
Unfortunately I was unable to create a test (at least one integrated with the Ant build) for this and got some unexpected errors while trying to do so.
So I would like someone to have a look at it. I don't think it should affect something else, but it seems I'm not really up-to-date with Ant :-(
The problem:
If you update a jar file and one of the filesets that are passed to the task are empty it throws a NPE.
Attached files: - jar.patch.txt - the patch to Jar.java - jar.test.patch - How I tried to integrate a test for that case - maybe someone can explain what I did wrong? - testcase.jar - a simple testcase, throws if NPE if Ant is run for the second time.
Nico
Index: Zip.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
retrieving revision 1.97
diff -u -r1.97 Zip.java
--- Zip.java 19 Feb 2003 07:57:29 -0000 1.97
+++ Zip.java 26 Feb 2003 00:13:17 -0000
@@ -750,6 +750,7 @@
for (int i = 0; i < filesets.length; i++) {
if (initialResources[i].length == 0) {
+ newerResources[i] = new Resource[] {};
continue;
}
Index: JarTest.java
===================================================================
RCS file:
/home/cvs/ant/src/testcases/org/apache/tools/ant/taskdefs/JarTest.java,v
retrieving revision 1.17
diff -u -r1.17 JarTest.java
--- JarTest.java 20 Feb 2003 17:15:46 -0000 1.17
+++ JarTest.java 26 Feb 2003 00:24:23 -0000
@@ -214,4 +214,9 @@
"testRecreateZipfilesetWithUpdateNewerFile");
}
+ public void testCreateWithEmptyFileset() {
+ executeTarget("testCreateWithEmptyFilesetSetUp");
+ executeTarget("testCreateWithEmptyFileset");
+ executeTarget("testCreateWithEmptyFileset");
+ }
}
Index: jar.xml
===================================================================
RCS file: /home/cvs/ant/src/etc/testcases/taskdefs/jar.xml,v
retrieving revision 1.8
diff -u -r1.8 jar.xml
--- jar.xml 23 Jan 2003 15:03:28 -0000 1.8
+++ jar.xml 26 Feb 2003 00:26:57 -0000
@@ -5,6 +5,8 @@
<property name="tmp.jar" location="tmp.jar"/>
<property name="tmp.dir" location="jartmp"/>
<property name="tmp.zip" location="tmp.zip"/>
+ <property name="tmp1.dir" location="jartmp1"/>
+ <property name="tmp2.dir" location="jartmp2"/>
<target name="test1">
<jar/>
@@ -166,6 +168,25 @@
<delete file="${tmp.jar}" />
<delete dir="${tmp.dir}"/>
<delete file="${tmp.zip}" />
+ <delete dir="${tmp1.dir}"/>
+ <delete dir="${tmp2.dir}"/>
+ </target>
+
+ <target name="testCreateWithEmptyFilesetSetUp">
+ <mkdir dir="${tmp1.dir}"/>
+ <mkdir dir="${tmp2.dir}"/>
+ <echo file="${tmp2.dir}/foo.txt" message="foo"/>
+ </target>
+
+ <target name="testCreateWithEmptyFileset">
+ <jar destfile="${tmp.jar}">
+ <fileset dir="${tmp1.dir}">
+ <include name="**/*.doesNotExist"/>
+ </fileset>
+ <fileset dir="${tmp2.dir}">
+ <include name="**/foo.txt"/>
+ </fileset>
+ </jar>
</target>
</project>
testcase.jar
Description: application/jar
