bodewig 01/03/08 03:03:41
Modified: src/etc/testcases/taskdefs zip.xml
src/main/org/apache/tools/ant/taskdefs Zip.java
src/testcases/org/apache/tools/ant/taskdefs ZipTest.java
Log:
Make sure zip files, that <zip> is reading from, will be closed.
Submitted by: David Rees <[EMAIL PROTECTED]>
Revision Changes Path
1.4 +28 -0 jakarta-ant/src/etc/testcases/taskdefs/zip.xml
Index: zip.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/src/etc/testcases/taskdefs/zip.xml,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- zip.xml 2001/03/02 15:57:31 1.3
+++ zip.xml 2001/03/08 11:03:38 1.4
@@ -25,9 +25,37 @@
basedir="."/>
</target>
+ <target name="test5">
+ <zip zipfile="test5.zip" basedir="." >
+ <exclude name="test5.zip" />
+ </zip>
+ </target>
+ <target name="test6">
+ <zip zipfile="test6.zip" basedir=".">
+ <include name="*.xml" />
+ <exclude name="zip.*" />
+ </zip>
+ </target>
+
+ <target name="test7">
+ <zip zipfile="inner7.zip" basedir="." >
+ <exclude name="inner7.zip" />
+ </zip>
+ <zip zipfile="test7.zip" basedir=".">
+ <exclude name="**/*.*" />
+ <zipfileset src="inner7.zip" />
+ </zip>
+ </target>
+
+
+
<target name="cleanup">
<delete file="test3.zip"/>
<delete file="test4.zip"/>
+ <delete file="test5.zip"/>
+ <delete file="test6.zip"/>
+ <delete file="inner7.zip"/>
+ <delete file="test7.zip"/>
</target>
</project>
1.32 +15 -7
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java
Index: Zip.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- Zip.java 2001/03/02 15:58:24 1.31
+++ Zip.java 2001/03/08 11:03:40 1.32
@@ -270,14 +270,22 @@
File zipSrc = fs.getSrc();
ZipEntry entry;
- ZipInputStream in = new ZipInputStream(new FileInputStream(zipSrc));
- while ((entry = in.getNextEntry()) != null) {
- String vPath = entry.getName();
- if (zipScanner.match(vPath)) {
- addParentDirs(null, vPath, zOut, prefix);
- if (! entry.isDirectory()) {
- zipFile(in, zOut, prefix+vPath, entry.getTime());
+ ZipInputStream in = null;
+ try {
+ in = new ZipInputStream(new FileInputStream(zipSrc));
+
+ while ((entry = in.getNextEntry()) != null) {
+ String vPath = entry.getName();
+ if (zipScanner.match(vPath)) {
+ addParentDirs(null, vPath, zOut, prefix);
+ if (! entry.isDirectory()) {
+ zipFile(in, zOut, prefix+vPath, entry.getTime());
+ }
}
+ }
+ } finally {
+ if (in != null) {
+ in.close();
}
}
}
1.4 +13 -0
jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java
Index: ZipTest.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/ZipTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ZipTest.java 2001/03/02 16:01:01 1.3
+++ ZipTest.java 2001/03/08 11:03:41 1.4
@@ -87,4 +87,17 @@
executeTarget("cleanup");
}
+ public void test5() {
+ executeTarget("test5");
+ }
+
+
+ public void test6() {
+ executeTarget("test6");
+ }
+
+
+ public void test7() {
+ executeTarget("test7");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]