You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Ray Chen (JIRA)" <ji...@apache.org> on 2009/12/09 03:52:18 UTC

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

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