[jboss-cvs] JBossAS SVN: r93907 - 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
Tue Sep 22 03:21:40 EDT 2009


Author: alesj
Date: 2009-09-22 03:21:40 -0400 (Tue, 22 Sep 2009)
New Revision: 93907

Modified:
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/CertificateReaderInputStream.java
   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/ZipFileLockReaper.java
   projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java
Log:
JBVFS-122 + generics

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/CertificateReaderInputStream.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/CertificateReaderInputStream.java	2009-09-22 05:44:48 UTC (rev 93906)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/CertificateReaderInputStream.java	2009-09-22 07:21:40 UTC (rev 93907)
@@ -25,8 +25,6 @@
 import java.io.InputStream;
 import java.util.zip.ZipEntry;
 
-import org.jboss.logging.Logger;
-
 /**
  * ZipEntryInputStream is part of ZipFileWrapper implementation.
  *
@@ -88,11 +86,6 @@
             if (entry instanceof EntryInfoAdapter)
                EntryInfoAdapter.class.cast(entry).readCertificates();
          }
-         catch (RuntimeException e)
-         {
-            Logger.getLogger(getClass()).error("ZipWraper:" + zipWrapper);
-            throw e;
-         }
          finally
          {
             zipWrapper.release();

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-09-22 05:44:48 UTC (rev 93906)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/EntryInfoAdapter.java	2009-09-22 07:21:40 UTC (rev 93907)
@@ -46,13 +46,13 @@
    }
 
    /**
-    * Get original entry.
+    * Update entry.
     *
-    * @return the original entry
+    * @param entry the new entry
     */
-   ZipEntry getOriginalEntry()
+   void updateEntry(ZipEntry entry)
    {
-      return ei.entry;
+      ei.entry = entry;      
    }
 
    /**

Modified: projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileLockReaper.java
===================================================================
--- projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileLockReaper.java	2009-09-22 05:44:48 UTC (rev 93906)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileLockReaper.java	2009-09-22 07:21:40 UTC (rev 93907)
@@ -21,12 +21,11 @@
 */
 package org.jboss.virtual.plugins.context.zip;
 
-import java.util.Iterator;
+import java.io.IOException;
 import java.util.Queue;
 import java.util.Timer;
 import java.util.TimerTask;
 import java.util.concurrent.ConcurrentLinkedQueue;
-import java.io.IOException;
 
 import org.jboss.logging.Logger;
 
@@ -75,7 +74,11 @@
    {
    }
 
-   /** Factory method to be used to retrieve reference to ZipFileLockReaper */
+   /**
+    * Factory method to be used to retrieve reference to ZipFileLockReaper.
+    *
+    * @return lock reaper singleton  
+    */
    public synchronized static ZipFileLockReaper getInstance()
    {
       if (singleton == null)
@@ -120,10 +123,8 @@
    {
       synchronized (ZipFileLockReaper.this)
       {
-         Iterator it = monitored.iterator();
-         while (it.hasNext())
+         for (ZipFileWrapper w : monitored)
          {
-            ZipFileWrapper w = (ZipFileWrapper) it.next();
             w.deleteFile(zipFileWrapper);
          }
       }
@@ -155,24 +156,8 @@
             }
          }
 
-         Iterator it = monitored.iterator();
-         while (it.hasNext())
+         for (ZipFileWrapper w : monitored)
          {
-            ZipFileWrapper w = (ZipFileWrapper) it.next();
-
-            // stream leak debug
-            /*
-            Iterator<ZipEntryInputStream> sit = w.streams.iterator();
-            while (sit.hasNext())
-            {
-               ZipEntryInputStream eis = sit.next();
-               if (!eis.isClosed())
-               {
-                  System.out.println("Stream not closed: " + eis.debugCount + " - " + eis);
-               }
-            }
-            */
-
             if (w.getReferenceCount() <= 0 && now - w.getLastUsed() > PERIOD)
             {
                try
@@ -181,7 +166,7 @@
                   if (log.isTraceEnabled())
                      log.trace("Asynchronously closed an unused ZipFile: " + w);
                }
-               catch(Exception ignored)
+               catch (Exception ignored)
                {
                   log.debug("IGNORING: Failed to close ZipFile: " + w, ignored);
                }

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-09-22 05:44:48 UTC (rev 93906)
+++ projects/vfs/branches/Branch_2_1/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java	2009-09-22 07:21:40 UTC (rev 93907)
@@ -188,7 +188,6 @@
       if (zipFile != null && getReferenceCount() <= 0)
       {
          ZipFile zf = zipFile;
-         //log.error(toString(), new Exception());
          zipFile = null;
          zf.close();
          if (forceNoReaper == false && noReaperOverride == false)
@@ -199,31 +198,28 @@
    /**
     * Get the contents of the given <tt>ZipEntry</tt> as stream
     *
-    * @param ent a zip entry
+    * @param entry a zip entry
     * @return an InputStream that locks the file for as long as it's open
     * @throws IOException for any error
     */
-   synchronized InputStream openStream(ZipEntry ent) throws IOException
+   synchronized InputStream openStream(ZipEntry entry) throws IOException
    {
       // JBVFS-57 JarInputStream composition
-      if (ent.isDirectory())
-         return recomposeZipAsInputStream(ent.getName());
+      if (entry.isDirectory())
+         return recomposeZipAsInputStream(entry.getName());
 
       ensureZipFile();
 
-      // do lookup on original
-      ZipEntry lookup;
-      if (ent instanceof EntryInfoAdapter)
-         lookup = EntryInfoAdapter.class.cast(ent).getOriginalEntry();
-      else
-         lookup = ent;
-
-      InputStream is = zipFile.getInputStream(lookup);
+      InputStream is = zipFile.getInputStream(entry);
       if (is == null)
-         throw new IOException("Entry no longer available: " + lookup.getName() + " in file " + file);
-      
-      InputStream zis = new CertificateReaderInputStream(lookup, this, is);
+         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(zipFile.getEntry(entry.getName()));
+
+      InputStream zis = new CertificateReaderInputStream(entry, this, is);
+
       incrementRef();
       return zis;
    }
@@ -401,7 +397,7 @@
     */
    public String toString()
    {
-      return super.toString() + " - " + file.getAbsolutePath() + " -- " + zipFile;
+      return super.toString() + " - " + file.getAbsolutePath();
    }
 
    /**




More information about the jboss-cvs-commits mailing list