This is the mail archive of the
java-patches@sources.redhat.com
mailing list for the Java project.
Re: Patch: java.util.zip.InflaterInputStream
- To: Tom Tromey <tromey at cygnus dot com>
- Subject: Re: Patch: java.util.zip.InflaterInputStream
- From: Mark Wielaard <mark at klomp dot org>
- Date: Thu, 24 Aug 2000 09:50:40 +0200
- Cc: Java Patch List <java-patches at sourceware dot cygnus dot com>
- References: <20000824004555.A29635@klomp.org> <87aee3bkkl.fsf@creche.cygnus.com>
Hi,
On Wed, Aug 23, 2000 at 05:54:02PM -0600, Tom Tromey wrote:
> >>>>> "Mark" == Mark Wielaard <mark@klomp.org> writes:
>
> Mark> The following patch catches the case where there is no more data
> Mark> to feed to the Inflater and throws an EOFException which is a
> Mark> bit nicer and more descriptive then the InternalError.
>
> Shouldn't we just return -1?
Hmmm. That does seem to solve my problem with the example jar that I send.
But is it really the correct thing to do? Inflater.needsInput() does return
true so it seems that fill() should be able to get more data from the
underlying compressed stream. But other InputStreams indeed signal a
premature end of data by just returning -1 and not by throwing an exception.
I will commit a patch that just returns -1 since that seems the correct
thing to do. But I am still uncertain why fill() cannot get more data in my
example case. Is there a way to verify that a zip/jar file is correct?
Cheers,
Mark
Here is the final patch. OK to commit?
2000-08-23 Mark Wielaard <mark@klomp.org>
* java/util/zip/InflaterInputStream.java (read(byte[],int,int)):
return -1 when fill() has no more data for the Inflater.
--- InflaterInputStream.java 2000/08/20 21:51:19 1.7
+++ InflaterInputStream.java 2000/08/24 07:48:55
@@ -65,6 +65,8 @@
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;
try