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) >
