Details
Description
Encountered while streaming zip data over a network:
In the createArchiveInputStream method of ArchiveStreamFactory, when the provided input stream is read, and it blocks before 12 bytes are available for reading, due to the contract of the java.io.InputStream class, the archive signature will not be completely read, and an ArchiveException will be thrown ("No Archiver found for the stream signature").
In ZipArchiveInputStream, you have implemented a readFully method, which should solve this issue, but since you are checking the length of the signature read against the expected length, you are never getting to do that. When you try to read the signature, you should be using readFully.
For reference, here is important part of the contract of java.io.InputStream.read():
This method blocks until [ANY] input data is available, end of file is detected, or an exception is thrown.
If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.