[jboss-cvs] JBossAS SVN: r90215 - in projects/vfs/trunk/src/main/java/org/jboss/virtual: spi/zip/jdk and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Jun 15 16:26:46 EDT 2009
Author: alesj
Date: 2009-06-15 16:26:46 -0400 (Mon, 15 Jun 2009)
New Revision: 90215
Added:
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/IgnoreCloseInputStream.java
Modified:
projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipFile.java
projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipProvider.java
Log:
Ignore close on ZipFile::inputStream.
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java 2009-06-15 20:13:35 UTC (rev 90214)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/plugins/context/zip/ZipFileWrapper.java 2009-06-15 20:26:46 UTC (rev 90215)
@@ -368,7 +368,17 @@
newEntry.setCrc(oldEntry.getCrc());
zout.putNextEntry(newEntry);
if (oldEntry.isDirectory() == false)
- VFSUtils.copyStream(zipFile.getInputStream(oldEntry), zout);
+ {
+ InputStream is = zipFile.getInputStream(oldEntry);
+ try
+ {
+ VFSUtils.copyStream(is, zout);
+ }
+ finally
+ {
+ is.close();
+ }
+ }
}
}
zout.close();
Added: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/IgnoreCloseInputStream.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/IgnoreCloseInputStream.java (rev 0)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/IgnoreCloseInputStream.java 2009-06-15 20:26:46 UTC (rev 90215)
@@ -0,0 +1,91 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.virtual.spi.zip.jdk;
+
+import java.io.InputStream;
+import java.io.IOException;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+class IgnoreCloseInputStream extends InputStream
+{
+ private InputStream delegate;
+
+ IgnoreCloseInputStream(InputStream zis)
+ {
+ this.delegate = zis;
+ }
+
+ public int read() throws IOException
+ {
+ return delegate.read();
+ }
+
+ @Override
+ public boolean markSupported()
+ {
+ return delegate.markSupported();
+ }
+
+ @Override
+ public void reset() throws IOException
+ {
+ delegate.reset();
+ }
+
+ @Override
+ public void mark(int readlimit)
+ {
+ delegate.mark(readlimit);
+ }
+
+ @Override
+ public void close() throws IOException
+ {
+ // no-op
+ }
+
+ @Override
+ public int available() throws IOException
+ {
+ return delegate.available();
+ }
+
+ @Override
+ public long skip(long n) throws IOException
+ {
+ return delegate.skip(n);
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException
+ {
+ return delegate.read(b, off, len);
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException
+ {
+ return delegate.read(b);
+ }
+}
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipFile.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipFile.java 2009-06-15 20:13:35 UTC (rev 90214)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipFile.java 2009-06-15 20:26:46 UTC (rev 90215)
@@ -46,7 +46,8 @@
public InputStream getInputStream(ZipEntry entry) throws IOException
{
Object unwrap = entry.unwrap();
- return file.getInputStream(java.util.zip.ZipEntry.class.cast(unwrap));
+ InputStream delegate = file.getInputStream(java.util.zip.ZipEntry.class.cast(unwrap));
+ return new IgnoreCloseInputStream(delegate);
}
public void close() throws IOException
Modified: projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipProvider.java
===================================================================
--- projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipProvider.java 2009-06-15 20:13:35 UTC (rev 90214)
+++ projects/vfs/trunk/src/main/java/org/jboss/virtual/spi/zip/jdk/JDKZipProvider.java 2009-06-15 20:26:46 UTC (rev 90215)
@@ -58,67 +58,4 @@
{
zis.close();
}
-
- private static class IgnoreCloseInputStream extends InputStream
- {
- private InputStream delegate;
-
- private IgnoreCloseInputStream(InputStream zis)
- {
- this.delegate = zis;
- }
-
- public int read() throws IOException
- {
- return delegate.read();
- }
-
- @Override
- public boolean markSupported()
- {
- return delegate.markSupported();
- }
-
- @Override
- public void reset() throws IOException
- {
- delegate.reset();
- }
-
- @Override
- public void mark(int readlimit)
- {
- delegate.mark(readlimit);
- }
-
- @Override
- public void close() throws IOException
- {
- // no-op
- }
-
- @Override
- public int available() throws IOException
- {
- return delegate.available();
- }
-
- @Override
- public long skip(long n) throws IOException
- {
- return delegate.skip(n);
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException
- {
- return delegate.read(b, off, len);
- }
-
- @Override
- public int read(byte[] b) throws IOException
- {
- return delegate.read(b);
- }
- }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list