ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kev Jackson <kevin.jack...@it.fts-vn.com>
Subject IsSigned use of apache zip
Date Wed, 25 Jan 2006 08:22:49 GMT
I've just bene browsing the code and I noticed that IsSigned uses the 
java.util.zip classes not the org.apache.tools.zip classes.

Now considering that apache zip has a nice closeQuietly method I thought 
I'd change the IsSigned code to use that, but before I commit anything - 
does anyone know of any reason why the following would fail?

(don't want to break anything...)

Index: 
D:/java_projects/ant-core-trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
===================================================================
--- 
D:/java_projects/ant-core-trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
   
(revision 372105)
+++ 
D:/java_projects/ant-core-trunk/src/main/org/apache/tools/ant/taskdefs/condition/IsSigned.java
   
(working copy)
@@ -19,12 +19,12 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.Enumeration;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.DataType;
+import org.apache.tools.zip.ZipEntry;
+import org.apache.tools.zip.ZipFile;
 
 /**
  * Checks whether a jarfile is signed: if the name of the
@@ -39,7 +39,7 @@
 
     private String name;
     private File file;
-
+   
    /**
      * The jarfile that is to be tested for the presence
      * of a signature.
@@ -72,7 +72,7 @@
         try {
             jarFile = new ZipFile(zipFile);
             if (null == name) {
-                Enumeration entries = jarFile.entries();
+                Enumeration entries = jarFile.getEntries();
                 while (entries.hasMoreElements()) {
                     String eName = ((ZipEntry) 
entries.nextElement()).getName();
                     if (eName.startsWith(SIG_START)
@@ -95,13 +95,7 @@
            
             return shortSig || longSig;
         } finally {
-            if (jarFile != null) {
-                try {
-                    jarFile.close();
-                } catch (IOException e) {
-                    // Ignored
-                }
-            }
+            ZipFile.closeQuietly(jarFile);
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message