InflaterInputStream (read): Don't return -1 unless the infate() call didn't deliver...
authorBryce McKinlay <bryce@albatross.co.nz>
Wed, 29 Nov 2000 10:06:03 +0000 (10:06 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Wed, 29 Nov 2000 10:06:03 +0000 (10:06 +0000)
* java/util/zip/InflaterInputStream (read): Don't return -1 unless
the infate() call didn't deliver any output. Throw a ZipException if
the needsDictionary() call returns true.
* java/io/ByteArrayInputStream (read): Remove redundant bounds checks.
* java/io/InputStreamReader: Use the default buffer size for the
contained BufferedInputStream.

From-SVN: r37846

libjava/ChangeLog
libjava/java/io/ByteArrayInputStream.java
libjava/java/io/InputStreamReader.java
libjava/java/util/zip/InflaterInputStream.java

index 5e6212f174d115e3544b8a0ae099da31bedd2e0d..57c04e0ccf63222fc6213a35bfcc6d060dcca01e 100644 (file)
@@ -5,6 +5,13 @@
        * configure.in: Check for setlocale.
        * configure: Rebuilt.
        * include/config.h.in: Rebuilt.
+       
+       * java/util/zip/InflaterInputStream (read): Don't return -1 unless
+       the infate() call didn't deliver any output. Throw a ZipException if
+       the needsDictionary() call returns true.
+       * java/io/ByteArrayInputStream (read): Remove redundant bounds checks.
+       * java/io/InputStreamReader: Use the default buffer size for the
+       contained BufferedInputStream.
 
 2000-11-28  Warren Levy  <warrenl@cygnus.com>
 
index 97ec6e7981840a86d570e828a7ef8baec2e77bdf..30ba8d7f9da58829ad65b4fca2a4775ac860d307 100644 (file)
@@ -72,9 +72,6 @@ public class ByteArrayInputStream extends InputStream
 
   public synchronized int read()
   {
-    if (pos < 0)
-      throw new ArrayIndexOutOfBoundsException(pos);
-
     if (pos < count)
       return ((int) buf[pos++]) & 0xFF;
     return -1;
@@ -82,10 +79,6 @@ public class ByteArrayInputStream extends InputStream
 
   public synchronized int read(byte[] b, int off, int len)
   {
-    /* Don't need to check pos value, arraycopy will check it. */
-    if (off < 0 || len < 0 || off + len > b.length)
-      throw new ArrayIndexOutOfBoundsException();
-
     if (pos >= count)
       return -1;
 
index 478d8ef599674f23c823c85f625430ad489115ec..73876fbd69140f11ded5d2c3a08c7fa0c23e31fe 100644 (file)
@@ -46,7 +46,7 @@ public class InputStreamReader extends Reader
   {
     this.in = in instanceof BufferedInputStream
               ? (BufferedInputStream) in
-              : new BufferedInputStream(in, 250);
+              : new BufferedInputStream(in);
     /* Don't need to call super(in) here as long as the lock gets set. */
     this.lock = in;
     converter = decoder;
index 005c82179d1d2baf164e2306fc21b2e5f625b789..d7459eb100d092515c865edc91c78d49c3c0d667 100644 (file)
@@ -44,8 +44,6 @@ public class InflaterInputStream extends FilterInputStream
 {
   protected void fill () throws IOException
   {
-    if (inf == null)
-      throw new IOException ("stream closed");
     len = in.read(buf, 0, buf.length);
     if (len != -1)
       inf.setInput(buf, 0, len);
@@ -85,18 +83,23 @@ public class InflaterInputStream extends FilterInputStream
       return -1;
     if (inf.needsInput())
       fill ();
-    if (this.len == -1)
-      return -1; // Couldn't get any more data to feed to the Inflater
-    if (inf.needsDictionary())
-      return -1;
+    int count;
     try
       {
-       return inf.inflate(buf, off, len);
+       count = inf.inflate(buf, off, len);     
+       if (count == 0)
+         {
+           if (len == -1)
+             return -1; // Couldn't get any more data to feed to the Inflater
+           if (inf.needsDictionary())
+             throw new ZipException ("Inflater needs Dictionary");
+         }           
       }
     catch (DataFormatException dfe)
       {
        throw new ZipException (dfe.getMessage());
       }
+    return count;
   }
 
   public void close () throws IOException