[jboss-cvs] JBossAS SVN: r70452 - projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 5 15:34:02 EST 2008


Author: scott.stark at jboss.org
Date: 2008-03-05 15:34:02 -0500 (Wed, 05 Mar 2008)
New Revision: 70452

Modified:
   projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java
Log:
JBVFS-17, deal with recursive jar serialization

Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java	2008-03-05 20:32:20 UTC (rev 70451)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/jar/NestedJarFromStream.java	2008-03-05 20:34:02 UTC (rev 70452)
@@ -196,6 +196,31 @@
    // Stream accessor
    public InputStream openStream() throws IOException
    {
+      if(zis == null)
+      {
+         // Need to obtain this nested jar input stream from parent
+         InputStream parentIS = super.getParent().openStream();
+         if(parentIS == null)
+            throw new IOException("Failed to open parent stream, "+this);
+         if(parentIS instanceof ZipInputStream)
+         {
+            zis = (ZipInputStream) parentIS;
+         }
+         else
+         {
+            zis = new ZipInputStream(parentIS);
+         }
+         // First find our entry
+         ZipEntry entry = zis.getNextEntry();
+         while(entry != null)
+         {
+            if(entry.getName().equals(getName()))
+               break;
+            entry = zis.getNextEntry();
+         }
+         if(entry == null)
+            throw new IOException("Failed to find nested jar entry: "+this.getName()+" in parent: "+getParent());
+      }
       return zis;
    }
 
@@ -305,14 +330,7 @@
          InputStream parentIS = super.getParent().openStream();
          if(parentIS == null)
             throw new IOException("Failed to open parent stream, "+this);
-         if(parentIS instanceof ZipInputStream)
-         {
-            jarStream = (ZipInputStream) parentIS;
-         }
-         else
-         {
-            jarStream = new ZipInputStream(parentIS);
-         }
+         jarStream = new ZipInputStream(parentIS);
          // First find our entry
          ZipEntry entry = jarStream.getNextEntry();
          while(entry != null)




More information about the jboss-cvs-commits mailing list