You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Vasily Zakharov (JIRA)" <ji...@apache.org> on 2007/04/18 22:40:15 UTC

[jira] Created: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

[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


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) passed, 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.


[jira] Reopened: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reopened HARMONY-3703:
--------------------------------------


reopened

> [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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496975 ] 

Vasily Zakharov commented on HARMONY-3703:
------------------------------------------

NetBeans runs fine with this updated patch.


> [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, H-3703_add.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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491999 ] 

Vasily Zakharov commented on HARMONY-3703:
------------------------------------------

Mikhail, I've checked the patch, it seems to resolve all the described problems both on DRL VM and IBM VM.

Thank you very much!


> [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
>         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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496832 ] 

Mikhail Markov commented on HARMONY-3703:
-----------------------------------------

The target of the test is to test the situation when trailer size is > 8 bytes (so trailer's structure will be: [crc (4 bytes)][size (4 bytes)][the rest - ignored].
This could be done in many ways. The mentioned way is the simplest one to add "the rest" part to the file as GZIPOutputStream writes to the stream when opening.
I could suggest another way: replace
        gout = new GZIPOutputStream(out); 
        gout.close(); 
with
        out.write(1);
        out.close();
The result of test will be the same.

> [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, H-3703_add.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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491953 ] 

Mikhail Markov commented on HARMONY-3703:
-----------------------------------------

I succeeded to reproduce the problem yesterday (i did not see it before due to the problem with Exception swallowing in IBM VME as mentioned above) and came to the same conclusion that the problem is indeed in processing the trailing of the file.
I'll provide the patch soon.

> [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
>
> 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.


[jira] Updated: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Markov updated HARMONY-3703:
------------------------------------

    Attachment: H-3703.patch

Here is the the patch fixing the problem.
It changes the previous weird algorithm of reading the trailer of GZip file (and sometimes leading to negative values etc.) with the new one. The steps of getting the trailer (8 bytes) are the following:
1) the first bytes are get from the buffer filled by InflaterInputStream.fill() method. The number of bytes copied is max(8, len of this fill buffer,  len input buffer after decompresstion, returned by Inflater.getRemaining() method).
2) The remaining bytes are read from the stream via readFully() method as before.

I've checked the patch on my machine and the above test passed.
Hope it'll fix all the cases described by Vasily (as i could not reproduce them on my machine).

Vasily, could you please check if this patch fix your problem, please?
Thanks!

> [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
>         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.


[jira] Assigned: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-3703:
----------------------------------------

    Assignee: Alexei Zakharov

> [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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Elena Sayapina (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12490915 ] 

Mikhail Markov commented on HARMONY-3703:
-----------------------------------------

Vasily, I could not reproduce the described problem on my WinXP.

On RI, J9 & DRLVM i get the same following output with your test (with the specified http address):
0
777
...
386865

Did you tried on Windows or on Linux?

> [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
>
> 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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491869 ] 

Vasily Zakharov commented on HARMONY-3703:
------------------------------------------

I've noticed that IBM VM in some cases "swallows" the unexpected exception diagnostic and terminates silently like everything is ok while in fact exception was thrown. Here's the updated test that takes care of this issue:

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) {
            System.out.println(length += num);
            try {
                num = stream.read(buffer, length, (buffer.length - length));
            } catch (Throwable t) {
                t.printStackTrace(System.out);
                System.out.println("FAIL");
                return;
            }
        }
        System.out.println("SUCCESS");
    }
}

I've run this test on my machine 1000 times on IBM VM with not a single SUCCESS. The following FAILs were observed:

java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(System.java:327)
	at java.lang.System.arraycopy(System.java:237)
	at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:164)
	at Test.main(Test.java:13)
(655 times, size is negative)

java.io.EOFException
	at java.util.zip.GZIPInputStream.readFully(GZIPInputStream.java:196)
	at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:168)
	at Test.main(Test.java:13)
(302 times, size is 0, 1 or 2)

java.io.IOException: Crc mismatch
	at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:170)
	at Test.main(Test.java:13)
(43 times, size is 8)

It looks like the particular outcome depends on the particular value of size variable on each run.


> [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
>
> 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.


[jira] Closed: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vasily Zakharov closed HARMONY-3703.
------------------------------------


Thank you Alexei, the patch works fine.

I suppose we don't need regression for this issue, as it's rather complex to create and requires Internet connection.

So I'm closing the issue.


> [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.


[jira] Updated: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Markov updated HARMONY-3703:
------------------------------------

    Attachment: H-3703_add.patch

Here is an additional patch fixing the mentioned problem + unit test.

There was a problem with previous one as it incorrectly works when the number of remaining bytes in the Inflater was more that 8 (in this case 2-nd parameter in arrycopy() call was incorrect as size was modified and thus (len -size) points to the wrong position).

> [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, H-3703_add.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.


[jira] Resolved: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov resolved HARMONY-3703.
--------------------------------------

    Resolution: Fixed

Looks much better, thanks Mikhail. Applied at the revision 539473. Please take a look.

> [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, H-3703_add.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.


[jira] Updated: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vasily Zakharov updated HARMONY-3703:
-------------------------------------

    Patch Info: [Patch Available]

> [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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496820 ] 

Alexei Zakharov commented on HARMONY-3703:
------------------------------------------

Mikhail, after I've corrected your test and removed the line

        }
        gout.finish();
-        gout = new GZIPOutputStream(out);
        gout.close();
        gis = new GZIPInputStream(new FileInputStream(f));

that looks like a typo the test started to pass even on the current version of the VM. So it seems the test needs to be reworked. 

> [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, H-3703_add.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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12496472 ] 

Mikhail Markov commented on HARMONY-3703:
-----------------------------------------

Elena, thanks for finding this out!

Alexei, could you please reopen this issue so I could add additional patch/regression test?

> [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.


[jira] Updated: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Vasily Zakharov updated HARMONY-3703:
-------------------------------------

    Description: 
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.


  was:
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) passed, 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.



> [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
>
> 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.


[jira] Closed: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov closed HARMONY-3703.
------------------------------------


closed once again

> [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, H-3703_add.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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491848 ] 

Vasily Zakharov commented on HARMONY-3703:
------------------------------------------

My investigations show that the problem probably lays in lines 149-169 of GZIPInputStream.java - in the block of code that handles the unpacking of the last chunk of data, when the underlying stream reports end-of-stream.

For example, size calculation in line 157 sometimes produces a negative value, causing ArrayIndexOutOfBoundsException in System.arraycopy() at line 161.


> [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
>
> 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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491107 ] 

Vasily Zakharov commented on HARMONY-3703:
------------------------------------------

I was able to reproduce the problem on IBM VM also, on heavily loaded machine. It looks pretty much like a race condition.


> [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
>
> 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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12491967 ] 

Vasily Zakharov commented on HARMONY-3703:
------------------------------------------

Great to hear that, thanks Mkhail!

Just for completeness, here's the statistics for DRL VM, also on 1000 runs:

SUCCESS
(293 times)

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:164)
        at Test.main(Test.java:13)
(242 times, size is negative)

java.io.EOFException
        at java.util.zip.GZIPInputStream.readFully(GZIPInputStream.java:196)
        at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:168)
        at Test.main(Test.java:13)
(455 times, size is 0, 1 or 2)

java.io.IOException: Crc mismatch
        at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:170)
        at Test.main(Test.java:13)
(10 times, size is 8)

Clearly, the problem is not VM-dependent, though some timing or synchronization issue is in place, so the relative amount of different types of failures is different.

I'm sure size variable value governs the particular failure outcome, but what affects that value it still unclear for me - it's different each time, on exactly the same data. Probably the speed or timing of data incoming from the network is the factor.


> [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
>
> 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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12490974 ] 

Vasily Zakharov commented on HARMONY-3703:
------------------------------------------

I've checked the problem again on the current build, the problem IS reproduced on DRL VM, but is NOT reproduced on IBM VM.

Mikhail, does it reproduce in your environment?



> [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
>
> 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.


[jira] Commented: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Vasily Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12490918 ] 

Vasily Zakharov commented on HARMONY-3703:
------------------------------------------

I've tried on WinXP also.

Do you get SUCCESS message?

The last size changes with time, as the specified URL is a news strip, it's ok.

Do you use the latest build? I'm now doing update and full rebuild of Harmony to verify the problem, could you please do the same?

Thank you!


> [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
>
> 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.


[jira] Resolved: (HARMONY-3703) [classlib][archive][netbeans] GZIPInputStream throws IOException when feeding from the network

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-3703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov resolved HARMONY-3703.
--------------------------------------

    Resolution: Fixed

Thanks guys. Slightly modified version of Mikhail's patch was applied at the revision 537883. Please verify it is ok.

> [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.