[jira] Created: (COMPRESS-125) BZip2CompressorInputStream throws IOException if underlying stream returns available() == 0

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (COMPRESS-125) BZip2CompressorInputStream throws IOException if underlying stream returns available() == 0

Gilles Sadowski (Jira)
BZip2CompressorInputStream throws IOException if underlying stream returns available() == 0
-------------------------------------------------------------------------------------------

                 Key: COMPRESS-125
                 URL: https://issues.apache.org/jira/browse/COMPRESS-125
             Project: Commons Compress
          Issue Type: Bug
          Components: Compressors
    Affects Versions: 1.1
            Reporter: Robert Lichtenberger
            Priority: Minor


BzipCompressorInput,init() will throw an IOException, if the passed stream returns 0 for available():
{code:title=BzipCompressorInput,.java|borderStyle=solid}
    private void init() throws IOException {
        ...
        if (in.available() == 0) {
            throw new IOException("Empty InputStream");
        }
        ...
     }
{code}

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".


--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] [Updated] (COMPRESS-125) BZip2CompressorInputStream throws IOException if underlying stream returns available() == 0

Gilles Sadowski (Jira)

     [ https://issues.apache.org/jira/browse/COMPRESS-125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb updated COMPRESS-125:
--------------------------

    Description:
BZip2CompressorInputStream,init() will throw an IOException, if the passed stream returns 0 for available():
{code:title=BZip2CompressorInputStream.java|borderStyle=solid}
    private void init() throws IOException {
        ...
        if (in.available() == 0) {
            throw new IOException("Empty InputStream");
        }
        ...
     }
{code}

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".


  was:
BzipCompressorInput,init() will throw an IOException, if the passed stream returns 0 for available():
{code:title=BzipCompressorInput,.java|borderStyle=solid}
    private void init() throws IOException {
        ...
        if (in.available() == 0) {
            throw new IOException("Empty InputStream");
        }
        ...
     }
{code}

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".



Fix class name

> BZip2CompressorInputStream throws IOException if underlying stream returns available() == 0
> -------------------------------------------------------------------------------------------
>
>                 Key: COMPRESS-125
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-125
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Compressors
>    Affects Versions: 1.1
>            Reporter: Robert Lichtenberger
>            Priority: Minor
>
> BZip2CompressorInputStream,init() will throw an IOException, if the passed stream returns 0 for available():
> {code:title=BZip2CompressorInputStream.java|borderStyle=solid}
>     private void init() throws IOException {
>         ...
>         if (in.available() == 0) {
>             throw new IOException("Empty InputStream");
>         }
>         ...
>      }
> {code}
> 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".

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (COMPRESS-125) BZip2CompressorInputStream throws IOException if underlying stream returns available() == 0

Gilles Sadowski (Jira)
In reply to this post by Gilles Sadowski (Jira)

     [ https://issues.apache.org/jira/browse/COMPRESS-125?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved COMPRESS-125.
---------------------------

       Resolution: Fixed
    Fix Version/s: 1.2

Agreed - the check serves no purpose and can cause unnecessary failures

> BZip2CompressorInputStream throws IOException if underlying stream returns available() == 0
> -------------------------------------------------------------------------------------------
>
>                 Key: COMPRESS-125
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-125
>             Project: Commons Compress
>          Issue Type: Bug
>          Components: Compressors
>    Affects Versions: 1.1
>            Reporter: Robert Lichtenberger
>            Priority: Minor
>             Fix For: 1.2
>
>
> BZip2CompressorInputStream,init() will throw an IOException, if the passed stream returns 0 for available():
> {code:title=BZip2CompressorInputStream.java|borderStyle=solid}
>     private void init() throws IOException {
>         ...
>         if (in.available() == 0) {
>             throw new IOException("Empty InputStream");
>         }
>         ...
>      }
> {code}
> 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".

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira