Well, good question :) As I already mentioned in comments for this issue,
inflate(...) should return 0 if needsInput() or or needsDictionary()  is
required. And the only exception which can be thrown is DataFormatException.
So, any internal error in zlib which is not related to data format should be
handled and inflate() should return zero in this case. Now let's get back to
zlib. According to the zlib documentation inflate returns Z_STREAM_ERROR if
"the stream structure was inconsistent (for example if next_in or next_out
was NULL)". And from my point of view it looks pretty similar to situation
when needsInput() is required.

For this particular case check for zero length can help, but IMHO we need to
handle all Z_STREAM_ERROR errors.


On 7/13/06, Mikhail Loenko <[EMAIL PROTECTED]> wrote:

Sergey

why you think we should return 0 in case of Z_STREAM_ERROR?

Don't we need just check for 0 the 'len' parameter?

Thanks,
Mikhail

2006/7/12, Sergey Soldatov (JIRA) <[EMAIL PROTECTED]>:
>    [
http://issues.apache.org/jira/browse/HARMONY-81?page=comments#action_12420584]
>
> Sergey Soldatov commented on HARMONY-81:
> ----------------------------------------
>
> Could someone check the attached diff ?
>
> > java.util.zip.Inflater.infalate() throws DataFormatException instead
of actual number of uncompressed bytes
> >
-----------------------------------------------------------------------------------------------------------
> >
> >          Key: HARMONY-81
> >          URL: http://issues.apache.org/jira/browse/HARMONY-81
> >      Project: Harmony
> >         Type: Bug
>
> >   Components: Classlib
> >     Reporter: Svetlana Samoilenko
> >  Attachments: harmony-81.diff
> >
> > Description:
> > According to the j2se 1.4 and 1.5 specification method
java.util.zip.Inflater.infalate(byte [] b, int off, int length ) returns
actual number of bytes uncompressed and throws DataFormatException if the
compressed data format is invalid.
> > The test listed below shows that Harmony throws DataFormatException
instead of return 0 (actual number of  uncompressed bytes).
> > Code to reproduce:
> > import java.util.zip.*;
> > public class test2 {
> >     public static void main(String[] args){
> >        Inflater inf = new Inflater();
> >        try {
> >           System.out.println("Inflater.inflate() = "+inf.inflate(new
byte[0], 0, 0));
> >        } catch(DataFormatException e) {
> >           e.printStackTrace();
> >        }
> > }
> > } Steps to Reproduce:
> > 1. Build Harmony (check-out on 2006-01-30) j2se subset as described in
README.txt.
> > 2. Compile test2.java using BEA 1.4 javac
> > > javac -d . test2.java
> > 3. Run java using compatible VM (J9)
> > > java -showversion test2
> > Output:
> > C:\tmp>C:\jrockit-j2sdk1.4.2_04\bin\java.exe -showversion test2
> > java version "1.4.2_04"
> > Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_04-b05)
> > BEA WebLogic JRockit(TM) 1.4.2_04 JVM (build
ari-31788-20040616-1132-win-ia32, Native Threads, GC strategy: parallel)
> > Inflater.inflate() = 0
> > C:\tmp>C:\harmony\trunk\deploy\jre\bin\java -showversion test2
> > (c) Copyright 1991, 2005 The Apache Software Foundation or its
licensors, as applicable.
> > java.util.zip.DataFormatException:
> >         at java.util.zip.Inflater.inflateImpl(Native Method)
> >         at java.util.zip.Inflater.inflate(Inflater.java:169)
> >         at test2.main(test2.java:7)
> >
> > Suggested junit test case:
> > ------------------------ 
InflaterTest.java-------------------------------------------------
> > import java.util.zip.*;
> > import junit.framework.*;
> > public class InflaterTest extends TestCase {
> >      public static void main(String[] args) {
> >         junit.textui.TestRunner.run(InflaterTest.class);
> >      }
> >      public void test_inflate () {
> >        Inflater inf = new Inflater();
> >        try {
> >            int n=inf.inflate(new byte[0], 0, 0);
> >            assertEquals(0, n);
> >        } catch(DataFormatException e) {
> >            fail("unexpected  DataFormatException");
> >        }
> >     }
> > }
>
> --
> This message is automatically generated by JIRA.
> -
> If you think it was sent incorrectly contact one of the administrators:
>   http://issues.apache.org/jira/secure/Administrators.jspa
> -
> For more information on JIRA, see:
>   http://www.atlassian.com/software/jira
>
>

---------------------------------------------------------------------
Terms of use : http://incubator.apache.org/harmony/mailing.html
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Sergey Soldatov
Intel Middleware Products Division

Reply via email to