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

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

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: 1.2
    • Component/s: Compressors
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: