Please use the attached patch _instead_ of the one in my previous
post. Sam functional changes, but also catches old case when zip
exists before run as well.

d

Index: src/etc/testcases/taskdefs/zip.xml
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/etc/testcases/taskdefs/zip.xml,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 zip.xml
--- src/etc/testcases/taskdefs/zip.xml  2001/02/19 13:30:06
1.2.2.1
+++ src/etc/testcases/taskdefs/zip.xml  2001/02/20 09:15:07
@@ -10,13 +10,24 @@
     <zip zipfile="zip.tmp"/>
   </target>
 
+  <!-- Test when the zip file includes itself
+  when target file exists before the zip task is run -->
   <target name="test3">
     <touch file="test3.zip"/>
-    <tar zipfile="test3.zip"
+    <zip zipfile="test3.zip"
          basedir="."/>
   </target>
-  
-  <target name="cleanup"> 
+
+  <!-- Test when the zip file includes itself
+  when target file does not exist before the zip task is run -->
+  <target name="test4">
+     <zip zipfile="test4.zip"
+         basedir="."/>
+  </target>
+
+
+  <target name="cleanup">
     <delete file="test3.zip"/>
+    <delete file="test4.zip"/>
   </target>
 </project>
Index: src/main/org/apache/tools/ant/taskdefs/Zip.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
retrieving revision 1.30.2.1
diff -u -r1.30.2.1 Zip.java
--- src/main/org/apache/tools/ant/taskdefs/Zip.java     2001/02/19
13:30:07        1.30.2.1
+++ src/main/org/apache/tools/ant/taskdefs/Zip.java     2001/02/20
09:15:08
@@ -465,6 +465,10 @@
     protected void zipFile(File file, ZipOutputStream zOut, String
vPath)
         throws IOException
     {
+        if (file.equals(zipFile)) {
+            throw new BuildException("A zip file cannot include
itself", location);
+        }
+
         FileInputStream fIn = new FileInputStream(file);
         try {
             zipFile(fIn, zOut, vPath, file.lastModified());
cvs server: cannot find
src/main/org/apache/tools/ant/taskdefs/optional/junit/AggregateTransformer.java
Index: src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java,v
retrieving revision 1.2.2.1
diff -u -r1.2.2.1 ZipTest.java
--- src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
2001/02/19 13:30:07     1.2.2.1
+++ src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
2001/02/20 09:15:11
@@ -77,6 +77,10 @@
     
     public void test3() { 
         expectBuildException("test3", "zip cannot include itself");
+    }
+
+    public void test4() { 
+        expectBuildException("test4", "zip cannot include itself");
     }
     
     public void tearDown() {

Reply via email to