You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Kevin Zhou (JIRA)" <ji...@apache.org> on 2009/06/29 15:33:47 UTC

[jira] Created: (HARMONY-6253) [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException

[classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException
------------------------------------------------------------------------------------------------

                 Key: HARMONY-6253
                 URL: https://issues.apache.org/jira/browse/HARMONY-6253
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M10
            Reporter: Kevin Zhou
             Fix For: 5.0M11


Given a test case [1], RI passes it smoothly while HARMONY throws a java.util.zip.ZipException [2].

[1] Test Case:
public void testJarInputStream() throws Exception {
    JarInputStream jarInputStream = new JarInputStream(new FileInputStream("lib/ant.jar"));
    JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream("lib/ant.jar.gz"));

    JarEntry jarEntry;
    byte[] bytes = new byte[1024];
    InputStream inputStream = new BufferedInputStream(jarInputStream);
    while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
        jarOutputStream.putNextEntry(jarEntry);
        int read = -1;
        while ((read = inputStream.read(bytes)) != -1) {
            jarOutputStream.write(bytes, 0, read);
        }
        jarOutputStream.closeEntry();
    }
    jarOutputStream.close();
}

[2] Stack Trace:
java.util.zip.ZipException: Size mismatch
at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:138)
at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:156)
at java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:160)
at java.util.jar.JarInputStream.getNextJarEntry(JarInputStream.java:111)
at Test.testJarInputStream(Test.java:22)

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


[jira] Updated: (HARMONY-6253) [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException

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

Mark Hindess updated HARMONY-6253:
----------------------------------

    Fix Version/s:     (was: 5.0M11)

This doesn't seem to be a regression or critical.  Removing fix for 5.0M11 status.


> [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6253
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6253
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M10
>            Reporter: Kevin Zhou
>         Attachments: ant.jar
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Given a test case [1], RI passes it smoothly while HARMONY throws a java.util.zip.ZipException [2].
> [1] Test Case:
> public void testJarInputStream() throws Exception {
>     JarInputStream jarInputStream = new JarInputStream(new FileInputStream("lib/ant.jar"));
>     JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream("lib/ant.jar.gz"));
>     JarEntry jarEntry;
>     byte[] bytes = new byte[1024];
>     InputStream inputStream = new BufferedInputStream(jarInputStream);
>     while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
>         jarOutputStream.putNextEntry(jarEntry);
>         int read = -1;
>         while ((read = inputStream.read(bytes)) != -1) {
>             jarOutputStream.write(bytes, 0, read);
>         }
>         jarOutputStream.closeEntry();
>     }
>     jarOutputStream.close();
> }
> [2] Stack Trace:
> java.util.zip.ZipException: Size mismatch
> at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:138)
> at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:156)
> at java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:160)
> at java.util.jar.JarInputStream.getNextJarEntry(JarInputStream.java:111)
> at Test.testJarInputStream(Test.java:22)

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


Re: [jira] Commented: (HARMONY-6253) [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException

Posted by Tim Ellison <t....@gmail.com>.
I looked at this one too.

In the specific test case given, the ZIP entry that causes problems is
org/apache/tools/ant/AntClassLoader.class

The local header says it has an uncompressed size of 17332 bytes, a CRC
of 3284205599, and a compressed size of 7747 bytes.

When we are done reading this ZIP entry we agree on the uncompressed
size and CRC, but we found the compressed size was only 7744 bytes.

Ray's proposal is that we remove the sanity check that the compressed
bytes agree, which will avoid the exception for sure!

I'm just going to poke around a bit more to see if I can find other code
that agrees that the full compressed form is indeed 7744 bytes and that
the directory entry is wrong and can be ignored, otherwise I'll have to
go looking for the mysterious three bytes.

Regards,
Tim


On 09/Dec/2009 03:12, Ray Chen (JIRA) wrote:
>     [ https://issues.apache.org/jira/browse/HARMONY-6253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12787890#action_12787890 ] 
> 
> Ray Chen commented on HARMONY-6253:
> -----------------------------------
> 
> Hi, I have attach one potential fix, please review it.
> 
>> [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException
>> ------------------------------------------------------------------------------------------------
>>
>>                 Key: HARMONY-6253
>>                 URL: https://issues.apache.org/jira/browse/HARMONY-6253
>>             Project: Harmony
>>          Issue Type: Bug
>>          Components: Classlib
>>    Affects Versions: 5.0M10
>>            Reporter: Kevin Zhou
>>         Attachments: 6253.diff, ant.jar
>>
>>   Original Estimate: 48h
>>  Remaining Estimate: 48h
>>
>> Given a test case [1], RI passes it smoothly while HARMONY throws a java.util.zip.ZipException [2].
>> [1] Test Case:
>> public void testJarInputStream() throws Exception {
>>     JarInputStream jarInputStream = new JarInputStream(new FileInputStream("lib/ant.jar"));
>>     JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream("lib/ant.jar.gz"));
>>     JarEntry jarEntry;
>>     byte[] bytes = new byte[1024];
>>     InputStream inputStream = new BufferedInputStream(jarInputStream);
>>     while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
>>         jarOutputStream.putNextEntry(jarEntry);
>>         int read = -1;
>>         while ((read = inputStream.read(bytes)) != -1) {
>>             jarOutputStream.write(bytes, 0, read);
>>         }
>>         jarOutputStream.closeEntry();
>>     }
>>     jarOutputStream.close();
>> }
>> [2] Stack Trace:
>> java.util.zip.ZipException: Size mismatch
>> at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:138)
>> at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:156)
>> at java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:160)
>> at java.util.jar.JarInputStream.getNextJarEntry(JarInputStream.java:111)
>> at Test.testJarInputStream(Test.java:22)
> 

[jira] Commented: (HARMONY-6253) [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException

Posted by "Ray Chen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-6253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12787890#action_12787890 ] 

Ray Chen commented on HARMONY-6253:
-----------------------------------

Hi, I have attach one potential fix, please review it.

> [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6253
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6253
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M10
>            Reporter: Kevin Zhou
>         Attachments: 6253.diff, ant.jar
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Given a test case [1], RI passes it smoothly while HARMONY throws a java.util.zip.ZipException [2].
> [1] Test Case:
> public void testJarInputStream() throws Exception {
>     JarInputStream jarInputStream = new JarInputStream(new FileInputStream("lib/ant.jar"));
>     JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream("lib/ant.jar.gz"));
>     JarEntry jarEntry;
>     byte[] bytes = new byte[1024];
>     InputStream inputStream = new BufferedInputStream(jarInputStream);
>     while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
>         jarOutputStream.putNextEntry(jarEntry);
>         int read = -1;
>         while ((read = inputStream.read(bytes)) != -1) {
>             jarOutputStream.write(bytes, 0, read);
>         }
>         jarOutputStream.closeEntry();
>     }
>     jarOutputStream.close();
> }
> [2] Stack Trace:
> java.util.zip.ZipException: Size mismatch
> at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:138)
> at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:156)
> at java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:160)
> at java.util.jar.JarInputStream.getNextJarEntry(JarInputStream.java:111)
> at Test.testJarInputStream(Test.java:22)

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


[jira] Updated: (HARMONY-6253) [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException

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

Ray Chen updated HARMONY-6253:
------------------------------

    Attachment: 6253.diff

Hi, I have investigated this issue, the exception is throwed at line 191 of ZipInputStream.java because currentEntry.compressedSize and inB are not equal, and currentEntry.compressedSize is set at line 140 of ZipOutputStream.java

It assumed that the output byte size should be equal to input byte size, but is this supposition right?

Even for RI, the size of ant.jar and ant.jar.gz are not equal. 

RI: ant.jar.gz < ant.jar   (958,439  bytes and 958,858  bytes )
Harmony: ant.jar.gz > ant.jar (966,972  bytes and 958,858  bytes)

So, in the patch I simply remove the comparison between currentEntry.compressedSize and inB, and didn't see any regression.

Any comments?





> [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6253
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6253
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M10
>            Reporter: Kevin Zhou
>         Attachments: 6253.diff, ant.jar
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Given a test case [1], RI passes it smoothly while HARMONY throws a java.util.zip.ZipException [2].
> [1] Test Case:
> public void testJarInputStream() throws Exception {
>     JarInputStream jarInputStream = new JarInputStream(new FileInputStream("lib/ant.jar"));
>     JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream("lib/ant.jar.gz"));
>     JarEntry jarEntry;
>     byte[] bytes = new byte[1024];
>     InputStream inputStream = new BufferedInputStream(jarInputStream);
>     while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
>         jarOutputStream.putNextEntry(jarEntry);
>         int read = -1;
>         while ((read = inputStream.read(bytes)) != -1) {
>             jarOutputStream.write(bytes, 0, read);
>         }
>         jarOutputStream.closeEntry();
>     }
>     jarOutputStream.close();
> }
> [2] Stack Trace:
> java.util.zip.ZipException: Size mismatch
> at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:138)
> at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:156)
> at java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:160)
> at java.util.jar.JarInputStream.getNextJarEntry(JarInputStream.java:111)
> at Test.testJarInputStream(Test.java:22)

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


[jira] Commented: (HARMONY-6253) [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-6253?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12788142#action_12788142 ] 

Tim Ellison commented on HARMONY-6253:
--------------------------------------

Ray wrote:
> It assumed that the output byte size should be equal to
> input byte size, but is this supposition right? 

I think you might be misunderstanding the test.  More info on the dev list...

> [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6253
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6253
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M10
>            Reporter: Kevin Zhou
>         Attachments: 6253.diff, ant.jar
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Given a test case [1], RI passes it smoothly while HARMONY throws a java.util.zip.ZipException [2].
> [1] Test Case:
> public void testJarInputStream() throws Exception {
>     JarInputStream jarInputStream = new JarInputStream(new FileInputStream("lib/ant.jar"));
>     JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream("lib/ant.jar.gz"));
>     JarEntry jarEntry;
>     byte[] bytes = new byte[1024];
>     InputStream inputStream = new BufferedInputStream(jarInputStream);
>     while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
>         jarOutputStream.putNextEntry(jarEntry);
>         int read = -1;
>         while ((read = inputStream.read(bytes)) != -1) {
>             jarOutputStream.write(bytes, 0, read);
>         }
>         jarOutputStream.closeEntry();
>     }
>     jarOutputStream.close();
> }
> [2] Stack Trace:
> java.util.zip.ZipException: Size mismatch
> at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:138)
> at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:156)
> at java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:160)
> at java.util.jar.JarInputStream.getNextJarEntry(JarInputStream.java:111)
> at Test.testJarInputStream(Test.java:22)

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


[jira] Updated: (HARMONY-6253) [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException

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

Kevin Zhou updated HARMONY-6253:
--------------------------------

    Attachment: ant.jar

The material for this test case.

> [classlib][archive] java.util.jar.JarInputStream.getNextJarEntry() should not throw ZipException
> ------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6253
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6253
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M10
>            Reporter: Kevin Zhou
>             Fix For: 5.0M11
>
>         Attachments: ant.jar
>
>   Original Estimate: 48h
>  Remaining Estimate: 48h
>
> Given a test case [1], RI passes it smoothly while HARMONY throws a java.util.zip.ZipException [2].
> [1] Test Case:
> public void testJarInputStream() throws Exception {
>     JarInputStream jarInputStream = new JarInputStream(new FileInputStream("lib/ant.jar"));
>     JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream("lib/ant.jar.gz"));
>     JarEntry jarEntry;
>     byte[] bytes = new byte[1024];
>     InputStream inputStream = new BufferedInputStream(jarInputStream);
>     while ((jarEntry = jarInputStream.getNextJarEntry()) != null) {
>         jarOutputStream.putNextEntry(jarEntry);
>         int read = -1;
>         while ((read = inputStream.read(bytes)) != -1) {
>             jarOutputStream.write(bytes, 0, read);
>         }
>         jarOutputStream.closeEntry();
>     }
>     jarOutputStream.close();
> }
> [2] Stack Trace:
> java.util.zip.ZipException: Size mismatch
> at java.util.zip.ZipInputStream.closeEntry(ZipInputStream.java:138)
> at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:156)
> at java.util.jar.JarInputStream.getNextEntry(JarInputStream.java:160)
> at java.util.jar.JarInputStream.getNextJarEntry(JarInputStream.java:111)
> at Test.testJarInputStream(Test.java:22)

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