harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Elena Sayapina (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network
Date Thu, 17 May 2007 04:24:16 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496467
] 

Elena Sayapina commented on HARMONY-3703:
-----------------------------------------

The following piece of code fails on Harmony-r538054, Harmony-r538431, but passes on Harmony-r537771:

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;

public class gzipTest {

            public static void main(String[] args) {

                GZIPInputStream gis = null;
                int result = 0;

                try {

                        byte[] buffer = new byte[] {1,2,3,4,5,6,7,8,9,10};
                        OutputStream out = new FileOutputStream("gzip");
                        System.out.println("Open GZIPOutputStream");
                        GZIPOutputStream gout = new GZIPOutputStream(out);
                        System.out.println("Write 100 bytes into GZIPOutputStream");
                        for(int i = 0; i < 10; i++) {
                                    gout.write(buffer);
                        }
                        System.out.println("Finish GZIPOutputStream");
                        gout.finish();
                        System.out.println("Open GZIPOutputStream");
                        gout = new GZIPOutputStream(out);
                        System.out.println("Close GZIPOutputStream");
                        gout.close();

                        System.out.println("Open GZIPInputStream");
                        gis = new GZIPInputStream(new FileInputStream("gzip"));
                        buffer = new byte[100];
                        System.out.println("Read 100 bytes from GZIPInputStream");
                        result = gis.read(buffer);

                        System.out.println("Read EOF");
                        result = gis.read();
                        gis.close();
                        if (result == -1) {
                                   System.out.println("TEST PASSED: result = " + result);
                        } else {
                                   System.out.println("TEST FAILED: result = " + result);
                        }
                } catch (Exception e) {
                        e.printStackTrace();
                        System.out.println("TEST FAILED: unexpected " + e);
                }
            }
}

 
Output on Harmony-r538054:

Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r538054, (May 15 2007), Windows/ia32/msvc 1310, release build
http://incubator.apache.org/harmony

Open GZIPOutputStream
Write 100 bytes into GZIPOutputStream
Finish GZIPOutputStream
Open GZIPOutputStream
Close GZIPOutputStream
Open GZIPInputStream
Read 100 bytes from GZIPInputStream
Read EOF
java.io.IOException: Crc mismatch
        at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:161)
        at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:104)
        at gzipTest.main(gzipTest.java:38)
TEST FAILED: unexpected java.io.IOException: Crc mismatch

Output on Harmony-r537771:

Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r537771, (May 14 2007), Windows/ia32/msvc 1310, release build
http://incubator.apache.org/harmony

Open GZIPOutputStream
Write 100 bytes into GZIPOutputStream
Finish GZIPOutputStream
Open GZIPOutputStream
Close GZIPOutputStream
Open GZIPInputStream
Read 100 bytes from GZIPInputStream
Read EOF
TEST PASSED: result = -1



> [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the
network
> ----------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3703
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3703
>             Project: Harmony
>          Issue Type: Bug
>          Components: App-Oriented Bug Reports, Classlib
>            Reporter: Vasily Zakharov
>         Assigned To: Alexei Zakharov
>         Attachments: H-3703.patch
>
>
> When java.util.zip.GZIPInputStream is passed a stream constructed from a network URL,
it throws IOException (Crc mismatch) at end-of-stream. If the same content is fed through
local file URL, the problem doesn't occur. It looks like some end-of-stream detection problem
is in place, or a race condition.
> public class Test {
>     public static void main(String args[]) throws Exception {
>         byte[] buffer = new byte[0x100000];
>         String url =
>                 "http://www.netbeans.org/updates/55_1.20_.xml.gz";
>                 //"file:55_1.20_.xml.gz";
>         java.io.InputStream stream = new java.util.zip.GZIPInputStream(new java.net.URL(url).openStream());
>         int length = 0, num = 0;
>         while (num >= 0) {
>             length += num;
>             System.out.println(length);
>             num = stream.read(buffer, length, (buffer.length - length));
>         }
>     }
> }
> $ Ri/bin/java -Dhttp.proxyHost=$PROXY_HOST -Dhttp.proxyPort=$PROXY_PORT Test
> 0
> 777
> 3392
> ...
> 386431
> SUCCESS
> $ HY/bin/java -Dhttp.proxyHost=$PROXY_HOST -Dhttp.proxyPort=$PROXY_PORT Test
> 0
> 777
> 3392
> ...
> 386431
> Exception in thread "main" java.io.IOException: Crc mismatch
>         at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:166)
>         at Test.main(Test.java:13)
> On IBM VM, this result is stable. On DRLVM, the test sometimes (rarely) passes, and sometimes
(also rarely) another exception occurs instead of IOException:
> Uncaught exception in main:
> java.lang.ArrayIndexOutOfBoundsException: bad arrayCopy
>         at java.lang.VMMemoryManager.arrayCopy(VMMemoryManager.java)
>         at java.lang.System.arraycopy(System.java:86)
>         at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:161)
>         at Test.main(Test.java:13)
> If content is previously downloaded (wget http://www.netbeans.org/updates/55_1.20_.xml.gz)
and local file URL is used instead of network URL (comment line 5, uncomment line 6), output
on Harmony becomes identical to output on RI.
> This problem was discovered while trying to run NetBeans on Harmony. 
> Issue HARMONY-3702 was also filed while investigating this one.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message