From d02bc1fb258dcb43215c0d671237c0dbbb74c4b9 Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Wed, 29 Nov 2000 10:06:03 +0000 Subject: InflaterInputStream (read): Don't return -1 unless the infate() call didn't deliver any output. * 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/java/util/zip/InflaterInputStream.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'libjava/java/util/zip') diff --git a/libjava/java/util/zip/InflaterInputStream.java b/libjava/java/util/zip/InflaterInputStream.java index 005c821..d7459eb 100644 --- a/libjava/java/util/zip/InflaterInputStream.java +++ b/libjava/java/util/zip/InflaterInputStream.java @@ -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 -- cgit v1.1