Nirmal Vettiankal created COMPRESS-622:
------------------------------------------

             Summary: Invalid ZIP throws different exception in 1.21
                 Key: COMPRESS-622
                 URL: https://issues.apache.org/jira/browse/COMPRESS-622
             Project: Commons Compress
          Issue Type: Bug
          Components: Archivers
    Affects Versions: 1.21
            Reporter: Nirmal Vettiankal
         Attachments: zbsm.tmp

I have an invalid zip file (attached) that is throwing a ZipException in 1.20 
and an IOException in 1.21.

 

With the following code:
{code:java}
import java.nio.file.Paths;
import org.apache.commons.compress.archivers.zip.ZipFile;

public class ApacheCompressTest {

    public static void main(String... args) {
        try {
            new ZipFile(Paths.get("src/main/resources/zbsm.tmp").toFile());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

} {code}
 

Output in 1.20:
{code:java}
java.util.zip.ZipException: Archive is not a ZIP archive
    at 
org.apache.commons.compress.archivers.zip.ZipFile.positionAtEndOfCentralDirectoryRecord(ZipFile.java:1141)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.positionAtCentralDirectory(ZipFile.java:1021)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.populateFromCentralDirectory(ZipFile.java:702)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:371)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:256)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:225)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:208)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:169)
    at ApacheCompressTest.main(ApacheCompressTest.java:8)
{code}
 

Output in 1.21:

 
{code:java}
java.io.IOException: Error on ZipFile 
/Volumes/workplace/Test/ApacheCompressRegression/ApacheCompressRegression/src/main/resources/zbsm.tmp
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:383)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:261)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:230)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:213)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:174)
    at ApacheCompressTest.main(ApacheCompressTest.java:8)
Caused by: java.util.zip.ZipException: Archive is not a ZIP archive
    at 
org.apache.commons.compress.archivers.zip.ZipFile.positionAtEndOfCentralDirectoryRecord(ZipFile.java:1221)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.positionAtCentralDirectory(ZipFile.java:1097)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.populateFromCentralDirectory(ZipFile.java:713)
    at 
org.apache.commons.compress.archivers.zip.ZipFile.<init>(ZipFile.java:376)
    ... 5 more
{code}
 

Was this an intended change?



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to