Uploaded image for project: 'Commons Compress'
  1. Commons Compress
  2. COMPRESS-239

ArchiveStreamFactory cannot create an ArchiveInputStream from any input stream that is blocking



    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: 1.6
    • Component/s: Archivers
    • Labels:
    • Environment:

      Windows Server 2008r1/r2, Ubuntu 12.10


      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.




            • Assignee:
              esaron Jon Neel
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: