[jboss-cvs] JBossAS SVN: r94604 - projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Oct 9 10:55:56 EDT 2009


Author: alesj
Date: 2009-10-09 10:55:56 -0400 (Fri, 09 Oct 2009)
New Revision: 94604

Modified:
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/EntryInfoAdapter.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java
Log:
Small opt; read certs only once, no need to update entry.

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/EntryInfoAdapter.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/EntryInfoAdapter.java	2009-10-09 14:35:48 UTC (rev 94603)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/EntryInfoAdapter.java	2009-10-09 14:55:56 UTC (rev 94604)
@@ -60,11 +60,25 @@
     */
    void readCertificates()
    {
-      ZipEntry entry = ei.entry;
-      if (ei.certificates == null && entry instanceof JarEntry)
+      if (ei.certificates == null)
       {
-         Certificate[] certs = JarEntry.class.cast(entry).getCertificates();
+         ZipEntry entry = ei.entry;
+
+         Certificate[] certs = null;
+         if (entry instanceof JarEntry)
+            certs = JarEntry.class.cast(entry).getCertificates();
+
          ei.certificates = (certs != null) ? certs : ZipEntryContext.EntryInfo.MARKER;
       }
    }
+
+   /**
+    * Do we require an update.
+    *
+    * @return true if we need to update entry
+    */
+   boolean requiresUpdate()
+   {
+      return ei.certificates == null;
+   }
 }
\ No newline at end of file

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java	2009-10-09 14:35:48 UTC (rev 94603)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java	2009-10-09 14:55:56 UTC (rev 94604)
@@ -210,15 +210,24 @@
 
       ensureZipFile();
 
+      EntryInfoAdapter adapter = null;
+      if (entry instanceof EntryInfoAdapter)
+         adapter = EntryInfoAdapter.class.cast(entry);
+
       // make sure input stream and certs reader work on the same update
-      ZipEntry update = zipFile.getEntry(entry.getName());
+      ZipEntry update;
+      if (adapter != null && adapter.requiresUpdate())
+         update = zipFile.getEntry(entry.getName());
+      else
+         update = entry; // using the old one is good enough, as we're done reading certs
+
       InputStream is = zipFile.getInputStream(update);
       if (is == null)
          throw new IOException("Entry no longer available: " + entry.getName() + " in file " + file);
 
       // we need to update entry, from the new zif file
-      if (entry instanceof EntryInfoAdapter)
-         EntryInfoAdapter.class.cast(entry).updateEntry(update);
+      if (adapter != null)
+         adapter.updateEntry(update);
 
       InputStream zis = new CertificateReaderInputStream(entry, this, is);
 




More information about the jboss-cvs-commits mailing list