You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Tim Allison (Jira)" <ji...@apache.org> on 2020/02/28 15:02:00 UTC

[jira] [Updated] (COMPRESS-506) ZipException when on ZipArchiveInputStream but not ZipFile

     [ https://issues.apache.org/jira/browse/COMPRESS-506?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Allison updated COMPRESS-506:
---------------------------------
    Attachment: ooo-5948.bau.zip

> ZipException when on ZipArchiveInputStream but not ZipFile
> ----------------------------------------------------------
>
>                 Key: COMPRESS-506
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-506
>             Project: Commons Compress
>          Issue Type: Task
>            Reporter: Tim Allison
>            Priority: Major
>         Attachments: ooo-5948.bau.zip
>
>
> Over on Apache Tika, we recently gathered files from a number of bug trackers.  We found that this file (https://bz.apache.org/ooo/attachment.cgi?id=17659) causes an exception with ZipArchiveInputStream but not with ZipFile.  Java's ZipInputStream silently stops after the second entry.
> linux commandline {{unzip}} is able to unzip the file without problems.
> JIRA is not allowing me to attach the file.
> To replicate the problem:
> {noformat}
>     @Test
>     public void testOneOff() throws Exception {
>         Path p = Paths.get(".../ooo-5948.bau");
>         try(ZipFile zip = new ZipFile(p.toFile())) {
>             Enumeration<ZipArchiveEntry> enm = zip.getEntries();
>             while (enm.hasMoreElements()) {
>                 ZipArchiveEntry zae = enm.nextElement();
>                 System.out.println("commons-compress zipFile: "+zae.getName());
>             }
>         }
>         try (InputStream is = Files.newInputStream(p)) {
>             try (ZipArchiveInputStream zais = new ZipArchiveInputStream(is)) {
>                 ZipArchiveEntry zae = zais.getNextZipEntry();
>                 while (zae != null) {
>                     System.out.println("commons-compress stream: " + zae.getName());
>                     zae = zais.getNextZipEntry();
>                 }
>             }
>         } catch (ZipException e) {
>             e.printStackTrace();
>         }
>         try (ZipInputStream zipInputStream = new ZipInputStream(Files.newInputStream(p))) {
>             ZipEntry ze = zipInputStream.getNextEntry();
>             while (ze != null) {
>                 System.out.println("java zip stream: " + ze.getName());
>                 ze = zipInputStream.getNextEntry();
>             }
>         }
>     }
> {noformat}
> output:
> {noformat}
> commons-compress zipFile: mimetype
> commons-compress zipFile: P0/content.xml
> commons-compress zipFile: P0/styles.xml
> commons-compress zipFile: P1/content.xml
> commons-compress zipFile: P1/styles.xml
> commons-compress zipFile: P2/content.xml
> commons-compress zipFile: P2/styles.xml
> commons-compress zipFile: P3/content.xml
> commons-compress zipFile: P3/styles.xml
> commons-compress zipFile: P4/content.xml
> commons-compress zipFile: P4/styles.xml
> commons-compress zipFile: P5/content.xml
> commons-compress zipFile: P5/styles.xml
> commons-compress zipFile: P6/content.xml
> commons-compress zipFile: P6/styles.xml
> commons-compress zipFile: P7/content.xml
> commons-compress zipFile: P7/styles.xml
> commons-compress zipFile: P8/content.xml
> commons-compress zipFile: P8/styles.xml
> commons-compress zipFile: P9/content.xml
> commons-compress zipFile: P9/styles.xml
> commons-compress zipFile: PF/content.xml
> commons-compress zipFile: PF/styles.xml
> commons-compress zipFile: BlockList.xml
> commons-compress zipFile: META-INF/manifest.xml
> commons-compress stream: mimetype
> commons-compress stream: P0/content.xml
> java.util.zip.ZipException: Unexpected record signature: 0X8074B50
> 	at org.apache.commons.compress.archivers.zip.ZipArchiveInputStream.getNextZipEntry(ZipArchiveInputStream.java:286)
> 	at org.apache.tika.detect.TestContainerAwareDetector.testOneOff(TestContainerAwareDetector.java:245)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:498)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
> 	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
> 	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
> 	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
> 	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
> 	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
> 	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
> 	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
> 	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
> 	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
> 	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
> 	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
> 	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
> java zip stream: mimetype
> java zip stream: P0/content.xml
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)