You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Galder Zamarreno (JIRA)" <ji...@apache.org> on 2009/07/02 18:33:47 UTC

[jira] Created: (HTTPCORE-199) ContentInputStream does not implement InputStream.available

ContentInputStream does not implement InputStream.available
-----------------------------------------------------------

                 Key: HTTPCORE-199
                 URL: https://issues.apache.org/jira/browse/HTTPCORE-199
             Project: HttpComponents HttpCore
          Issue Type: Bug
          Components: HttpCore NIO
    Affects Versions: 4.0.1
            Reporter: Galder Zamarreno


I'm having an issue with ContentInputStream because it does not
override IS.available() method. Our client code is implemented in such
way that available() is checked before creating a buffer so that a not
too big buffer is created. Javadoc for IS.available says:

    * <p> This method should be overridden by subclasses.

Hence, ContentInputStream should be overriding it. However,
ContentInputBuffer does to expose the necessary methods to be able
calculate this but the implementations do have the possibility of
calculating this, i.e. SimpleInputBuffer. Any chance of improving
ContentInputBuffer API so that an available() method is added? If so,
what would be the timeframe for it?

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Updated: (HTTPCORE-199) ContentInputStream does not implement InputStream.available

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCORE-199:
---------------------------------------

    Fix Version/s: 4.1

Galder,

The contract of InputStream#available() is to return "the number of bytes that can be read (or skipped over) from this input stream without _blocking_ by the next caller of a method for this input stream". Therefore, it is perfectly legal to return 0, if the next invocation of #read method will cause the operation to block.

Basically InputStream#available() is utterly broken.

Anyway, please test the patch attached to this issue and let me know if that fixes the problem for you.

Oleg

> ContentInputStream does not implement InputStream.available
> -----------------------------------------------------------
>
>                 Key: HTTPCORE-199
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-199
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Galder Zamarreno
>             Fix For: 4.1
>
>         Attachments: HTTPCORE-199.patch
>
>
> I'm having an issue with ContentInputStream because it does not
> override IS.available() method. Our client code is implemented in such
> way that available() is checked before creating a buffer so that a not
> too big buffer is created. Javadoc for IS.available says:
>     * <p> This method should be overridden by subclasses.
> Hence, ContentInputStream should be overriding it. However,
> ContentInputBuffer does to expose the necessary methods to be able
> calculate this but the implementations do have the possibility of
> calculating this, i.e. SimpleInputBuffer. Any chance of improving
> ContentInputBuffer API so that an available() method is added? If so,
> what would be the timeframe for it?

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCORE-199) ContentInputStream does not implement InputStream.available

Posted by "Galder Zamarreno (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12727423#action_12727423 ] 

Galder Zamarreno commented on HTTPCORE-199:
-------------------------------------------

Oleg, I know that returning 0 is perfectly legal but your ContentInputStream is retuning 0 even when there are bytes that I can read. 
Personally, InputStream.available() should have been made abstract rather than simply return 0, otherwise input streams extending it could easily forget to reimplement it.

I'll try the patch asap.

> ContentInputStream does not implement InputStream.available
> -----------------------------------------------------------
>
>                 Key: HTTPCORE-199
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-199
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Galder Zamarreno
>             Fix For: 4.1
>
>         Attachments: HTTPCORE-199.patch
>
>
> I'm having an issue with ContentInputStream because it does not
> override IS.available() method. Our client code is implemented in such
> way that available() is checked before creating a buffer so that a not
> too big buffer is created. Javadoc for IS.available says:
>     * <p> This method should be overridden by subclasses.
> Hence, ContentInputStream should be overriding it. However,
> ContentInputBuffer does to expose the necessary methods to be able
> calculate this but the implementations do have the possibility of
> calculating this, i.e. SimpleInputBuffer. Any chance of improving
> ContentInputBuffer API so that an available() method is added? If so,
> what would be the timeframe for it?

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Resolved: (HTTPCORE-199) ContentInputStream does not implement InputStream.available

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski resolved HTTPCORE-199.
----------------------------------------

    Resolution: Fixed

Patch committed to the SVN trunk.

Oleg

> ContentInputStream does not implement InputStream.available
> -----------------------------------------------------------
>
>                 Key: HTTPCORE-199
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-199
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Galder Zamarreno
>             Fix For: 4.1
>
>         Attachments: HTTPCORE-199.patch
>
>
> I'm having an issue with ContentInputStream because it does not
> override IS.available() method. Our client code is implemented in such
> way that available() is checked before creating a buffer so that a not
> too big buffer is created. Javadoc for IS.available says:
>     * <p> This method should be overridden by subclasses.
> Hence, ContentInputStream should be overriding it. However,
> ContentInputBuffer does to expose the necessary methods to be able
> calculate this but the implementations do have the possibility of
> calculating this, i.e. SimpleInputBuffer. Any chance of improving
> ContentInputBuffer API so that an available() method is added? If so,
> what would be the timeframe for it?

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Updated: (HTTPCORE-199) ContentInputStream does not implement InputStream.available

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HTTPCORE-199?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Oleg Kalnichevski updated HTTPCORE-199:
---------------------------------------

    Attachment: HTTPCORE-199.patch

> ContentInputStream does not implement InputStream.available
> -----------------------------------------------------------
>
>                 Key: HTTPCORE-199
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-199
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Galder Zamarreno
>             Fix For: 4.1
>
>         Attachments: HTTPCORE-199.patch
>
>
> I'm having an issue with ContentInputStream because it does not
> override IS.available() method. Our client code is implemented in such
> way that available() is checked before creating a buffer so that a not
> too big buffer is created. Javadoc for IS.available says:
>     * <p> This method should be overridden by subclasses.
> Hence, ContentInputStream should be overriding it. However,
> ContentInputBuffer does to expose the necessary methods to be able
> calculate this but the implementations do have the possibility of
> calculating this, i.e. SimpleInputBuffer. Any chance of improving
> ContentInputBuffer API so that an available() method is added? If so,
> what would be the timeframe for it?

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCORE-199) ContentInputStream does not implement InputStream.available

Posted by "Galder Zamarreno (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12727448#action_12727448 ] 

Galder Zamarreno commented on HTTPCORE-199:
-------------------------------------------

The patch provided appears to fix the issue. When you do expect to a do a release with this fix?

Oleg, thanks very much for providing the fix so quickly :)

> ContentInputStream does not implement InputStream.available
> -----------------------------------------------------------
>
>                 Key: HTTPCORE-199
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-199
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Galder Zamarreno
>             Fix For: 4.1
>
>         Attachments: HTTPCORE-199.patch
>
>
> I'm having an issue with ContentInputStream because it does not
> override IS.available() method. Our client code is implemented in such
> way that available() is checked before creating a buffer so that a not
> too big buffer is created. Javadoc for IS.available says:
>     * <p> This method should be overridden by subclasses.
> Hence, ContentInputStream should be overriding it. However,
> ContentInputBuffer does to expose the necessary methods to be able
> calculate this but the implementations do have the possibility of
> calculating this, i.e. SimpleInputBuffer. Any chance of improving
> ContentInputBuffer API so that an available() method is added? If so,
> what would be the timeframe for it?

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


[jira] Commented: (HTTPCORE-199) ContentInputStream does not implement InputStream.available

Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12727456#action_12727456 ] 

Oleg Kalnichevski commented on HTTPCORE-199:
--------------------------------------------

Galder,

Provided everything goes well I am planning to have 4.1-ALPHA1 released sometime in early August.

Oleg

> ContentInputStream does not implement InputStream.available
> -----------------------------------------------------------
>
>                 Key: HTTPCORE-199
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-199
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.0.1
>            Reporter: Galder Zamarreno
>             Fix For: 4.1
>
>         Attachments: HTTPCORE-199.patch
>
>
> I'm having an issue with ContentInputStream because it does not
> override IS.available() method. Our client code is implemented in such
> way that available() is checked before creating a buffer so that a not
> too big buffer is created. Javadoc for IS.available says:
>     * <p> This method should be overridden by subclasses.
> Hence, ContentInputStream should be overriding it. However,
> ContentInputBuffer does to expose the necessary methods to be able
> calculate this but the implementations do have the possibility of
> calculating this, i.e. SimpleInputBuffer. Any chance of improving
> ContentInputBuffer API so that an available() method is added? If so,
> what would be the timeframe for it?

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org