Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Pointer Exception at getting inputstream #85

Closed
jackielii opened this issue Oct 11, 2019 · 1 comment
Closed

Null Pointer Exception at getting inputstream #85

jackielii opened this issue Oct 11, 2019 · 1 comment
Assignees
Labels
bug Something isn't working resolved

Comments

@jackielii
Copy link

with the following code

        val fn = "bigfile.zip"
        val zipFile = ZipFile(fn)
        val fh = zipFile.fileHeaders.firstOrNull()
        fh?.let {
            println(it.fileName)
            val input = zipFile.getInputStream(it)
        }

exception thrown at last line zipFile.getInputStream

I tracked it down through debugging, the exception is thrown at getCompressedSize:

java.lang.NullPointerException
	at net.lingala.zip4j.io.inputstream.ZipInputStream.getCompressedSize(ZipInputStream.java:290)
	at net.lingala.zip4j.io.inputstream.ZipInputStream.initializeEntryInputStream(ZipInputStream.java:199)
	at net.lingala.zip4j.io.inputstream.ZipInputStream.getNextEntry(ZipInputStream.java:106)
	at net.lingala.zip4j.util.UnzipUtil.createZipInputStream(UnzipUtil.java:29)
	at net.lingala.zip4j.ZipFile.getInputStream(ZipFile.java:782)

but It's actually because the compressionMethod is null :
image

The root cause is because the compression code is 9 and it's not supported:

image

   4.4.5 compression method: (2 bytes)

        0 - The file is stored (no compression)
        1 - The file is Shrunk
        2 - The file is Reduced with compression factor 1
        3 - The file is Reduced with compression factor 2
        4 - The file is Reduced with compression factor 3
        5 - The file is Reduced with compression factor 4
        6 - The file is Imploded
        7 - Reserved for Tokenizing compression algorithm
        8 - The file is Deflated
        9 - Enhanced Deflating using Deflate64(tm)
       10 - PKWARE Data Compression Library Imploding (old IBM TERSE)
       11 - Reserved by PKWARE
       12 - File is compressed using BZIP2 algorithm
       13 - Reserved by PKWARE
       14 - LZMA
       15 - Reserved by PKWARE
       16 - IBM z/OS CMPSC Compression
       17 - Reserved by PKWARE
       18 - File is compressed using IBM TERSE (new)
       19 - IBM LZ77 z Architecture (PFS)
       96 - JPEG variant
       97 - WavPack compressed data
       98 - PPMd version I, Rev 1
       99 - AE-x encryption marker (see APPENDIX E)

So instead of returning null, it should really throw an exception here...

@srikanth-lingala srikanth-lingala self-assigned this Oct 11, 2019
@srikanth-lingala srikanth-lingala added the bug Something isn't working label Oct 11, 2019
@srikanth-lingala
Copy link
Owner

srikanth-lingala commented Oct 19, 2019

Fixed in v2.2.3 released today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved
Projects
None yet
Development

No branches or pull requests

2 participants