This patch fixes bug #24596 and #26930.
For ZipFile.getInputStream(), Sun returns an InflatorInputStream (as do
we) and returns the size of the ZipEntry for that instance's available()
function.

Despite what the API says for InflatorInputStream.available(), Sun has
overridden this function for the instance returned by 
ZipFile.getInputStream. InflatorInputStream.available() works according
to the API for any other instance.

This patch fixes ZipFile to do the same.


2006-04-03  Lillian Angel  <[EMAIL PROTECTED]>

        PR classpath/24596 and PR classpath/26930
        * java/util/zip/ZipFile.java
        (getInputStream): Override available function for
        InflaterInputStream instance.

Index: java/util/zip/ZipFile.java
===================================================================
RCS file: /sources/classpath/classpath/java/util/zip/ZipFile.java,v
retrieving revision 1.30
diff -u -r1.30 ZipFile.java
--- java/util/zip/ZipFile.java	16 Mar 2006 14:30:11 -0000	1.30
+++ java/util/zip/ZipFile.java	3 Apr 2006 20:44:11 -0000
@@ -445,7 +445,16 @@
       case ZipOutputStream.STORED:
 	return inp;
       case ZipOutputStream.DEFLATED:
-	return new InflaterInputStream(inp, new Inflater(true));
+        final int sz = (int) entry.getSize();
+        return new InflaterInputStream(inp, new Inflater(true))
+        {
+          public int available() throws IOException
+          {
+            if (super.available() != 0)
+              return sz;
+            return 0;
+          }
+        };
       default:
 	throw new ZipException("Unknown compression method " + method);
       }

Reply via email to