harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r823479 - in /harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar: JarFile.java Manifest.java
Date Fri, 09 Oct 2009 09:35:06 GMT
Author: tellison
Date: Fri Oct  9 09:35:05 2009
New Revision: 823479

URL: http://svn.apache.org/viewvc?rev=823479&view=rev
Log:
Create a package private constructor for a Manifest from a byte array, so that we don't have
to read the ZIP entry stream twice when verifying.

Modified:
    harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java
    harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java?rev=823479&r1=823478&r2=823479&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/JarFile.java
Fri Oct  9 09:35:05 2009
@@ -336,15 +336,11 @@
         }
         try {
             InputStream is = super.getInputStream(manifestEntry);
+            byte[] buffer = getAllBytesFromStreamAndClose(is);
             if (verifier != null) {
-                verifier.addMetaEntry(manifestEntry.getName(), getAllBytesFromStreamAndClose(is));
-                is = super.getInputStream(manifestEntry);
-            }
-            try {
-                manifest = new Manifest(is, verifier != null);
-            } finally {
-                is.close();
+                verifier.addMetaEntry(manifestEntry.getName(), buffer);
             }
+            manifest = new Manifest(buffer, verifier != null);
             manifestEntry = null;
         } catch (NullPointerException e) {
             manifestEntry = null;

Modified: harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java?rev=823479&r1=823478&r2=823479&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/archive/src/main/java/java/util/jar/Manifest.java
Fri Oct  9 09:35:05 2009
@@ -115,6 +115,13 @@
         }
         read(is);
     }
+    
+    Manifest(byte[] buf, boolean readChunks) throws IOException {
+        if (readChunks) {
+            chunks = new HashMap<String, Chunk>();
+        }
+        initFromBytes(buf);
+    }
 
     /**
      * Resets the both the main attributes as well as the entry attributes
@@ -226,6 +233,13 @@
             buf[buf.length - 1] = '\n';
         }
 
+        initFromBytes(buf);
+    }
+
+    void initFromBytes(byte[] buf) throws IOException {
+        if (buf.length == 0) {
+            return;
+        }
         // Attributes.Name.MANIFEST_VERSION is not used for
         // the second parameter for RI compatibility
         im = new InitManifest(buf, mainAttributes, null);



Mime
View raw message