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

BZip2CompressorInputStream throws IOException if underlying stream returns available() == 0

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.1
    • 1.2
    • Compressors
    • None

    Description

      BZip2CompressorInputStream,init() will throw an IOException, if the passed stream returns 0 for available():

      BZip2CompressorInputStream.java
          private void init() throws IOException {
              ...
              if (in.available() == 0) {
                  throw new IOException("Empty InputStream");
              }
              ...
           }
      

      I think this is not correct, because the underlying stream may indeed be able to only return 0 bytes without blocking but may be able to block a little and then return some more bytes.
      Note also the change in the API documentation from: "Returns the number of bytes that can be read " (1.4.2) to "Returns an estimate of the number of bytes that can be read".

      Attachments

        Activity

          People

            Unassigned Unassigned
            effad Robert Lichtenberger
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: