You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Adam Bryzak (JIRA)" <ji...@apache.org> on 2009/02/25 10:13:02 UTC

[jira] Created: (HTTPCLIENT-829) ChunkedInputStream does not handle sockets with timeouts

ChunkedInputStream does not handle sockets with timeouts
--------------------------------------------------------

                 Key: HTTPCLIENT-829
                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-829
             Project: HttpComponents HttpClient
          Issue Type: Bug
    Affects Versions: 3.1 Final
            Reporter: Adam Bryzak


ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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: (HTTPCLIENT-829) ChunkedInputStream does not handle sockets with timeouts

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

Adam Bryzak updated HTTPCLIENT-829:
-----------------------------------

    Attachment: HTTPCLIENT-829.patch

Created a patch which stores some local variables in fields instead.

> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCLIENT-829
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-829
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 3.1 Final
>            Reporter: Adam Bryzak
>         Attachments: HTTPCLIENT-829.patch
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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: (HTTPCLIENT-829) ChunkedInputStream does not handle sockets with timeouts

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

Oleg Kalnichevski commented on HTTPCLIENT-829:
----------------------------------------------

Adam,

I am sorry but I do not see how SocketTimeoutException is related to ChunkedInputStream. ChunkedInputStream, like all other stream codecs, simply propagate IOExceptions to the caller.

Could you please demonstrate the problem with 4.0 code using a test case?

Oleg

> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCLIENT-829
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-829
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 3.1 Final
>            Reporter: Adam Bryzak
>         Attachments: HTTPCLIENT-829.patch
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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: (HTTPCLIENT-829) ChunkedInputStream does not handle sockets with timeouts

Posted by "Adam Bryzak (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCLIENT-829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12676650#action_12676650 ] 

Adam Bryzak commented on HTTPCLIENT-829:
----------------------------------------

When getting a SocketTimeoutException, the connection is still valid. In my project, I'm using the timeout as an opportunity to check if the connection should be terminated (for potentially various reasons such as how many active connections there are, how long the connection has been invalid or even if the service should no longer be running). The code for ChunkedInputStream in 4.0 looked to be similar or the same as in 3.1 which is what led me to believe it would still be a problem in it. The main issue is that it doesn't track all state as it's reading.

> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCLIENT-829
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-829
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 3.1 Final
>            Reporter: Adam Bryzak
>         Attachments: HTTPCLIENT-829.patch
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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: (HTTPCLIENT-829) ChunkedInputStream does not handle sockets with timeouts

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

Oleg Kalnichevski commented on HTTPCLIENT-829:
----------------------------------------------

Adam,

Socket timeouts are signalled as SocketTimeoutException. In case of a socket timeout there will be no more attempts to read from the input stream. Probably you mean end of stream condition, not a timeout? 

There is basically no point fixing HttpClient 3.x, as it is nearing its end of life. 

By looking at the code I do not think HttpClient 4.0 is affected. I believe the end of stream conditions are handled correctly. If you are able to reproduce the problem with HttpClient 4.0, feel free to submit a patch or a test case. Otherwise I'll close this issue as won't fix.

Oleg



> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCLIENT-829
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-829
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 3.1 Final
>            Reporter: Adam Bryzak
>         Attachments: HTTPCLIENT-829.patch
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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-190) ChunkedInputStream does not handle sockets with timeouts

Posted by "Adam Bryzak (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680451#action_12680451 ] 

Adam Bryzak commented on HTTPCORE-190:
--------------------------------------

ChunkedInputStream now behaves correctly when receiving a SocketTimeoutException in all my tests.

> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCORE-190
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-190
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>    Affects Versions: 4.0
>            Reporter: Adam Bryzak
>            Priority: Minor
>             Fix For: 4.1
>
>         Attachments: HTTPCLIENT-829.patch, HttpClient_829.java
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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: (HTTPCLIENT-829) ChunkedInputStream does not handle sockets with timeouts

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

Adam Bryzak updated HTTPCLIENT-829:
-----------------------------------

    Attachment: HttpClient_829.java

Attached a simple test case. Simply run the attached file with httpcore-4.0.jar in your classpath.

The test starts a simple http server which will respond with "012" chunked with 2 seconds between each chunk. It then connects a client with a timeout of 1 second and reads the data from the response 1 character at a time. After the first character the exception is thrown.

Note that this is just a Java class with a main method, and not a JUnit test case.

> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCLIENT-829
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-829
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>    Affects Versions: 3.1 Final
>            Reporter: Adam Bryzak
>         Attachments: HTTPCLIENT-829.patch, HttpClient_829.java
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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] Closed: (HTTPCORE-190) ChunkedInputStream does not handle sockets with timeouts

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

Oleg Kalnichevski closed HTTPCORE-190.
--------------------------------------


> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCORE-190
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-190
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>    Affects Versions: 4.0
>            Reporter: Adam Bryzak
>            Priority: Minor
>             Fix For: 4.1
>
>         Attachments: HTTPCLIENT-829.patch, HttpClient_829.java
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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] Moved: (HTTPCORE-190) ChunkedInputStream does not handle sockets with timeouts

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

Oleg Kalnichevski moved HTTPCLIENT-829 to HTTPCORE-190:
-------------------------------------------------------

    Affects Version/s:     (was: 3.1 Final)
                       4.0
                  Key: HTTPCORE-190  (was: HTTPCLIENT-829)
              Project: HttpComponents HttpCore  (was: HttpComponents HttpClient)

> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCORE-190
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-190
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>    Affects Versions: 4.0
>            Reporter: Adam Bryzak
>             Fix For: 4.1
>
>         Attachments: HTTPCLIENT-829.patch, HttpClient_829.java
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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-190) ChunkedInputStream does not handle sockets with timeouts

Posted by "Adam Bryzak (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HTTPCORE-190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12680316#action_12680316 ] 

Adam Bryzak commented on HTTPCORE-190:
--------------------------------------

I'll try and get around to testing it later today.

> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCORE-190
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-190
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>    Affects Versions: 4.0
>            Reporter: Adam Bryzak
>            Priority: Minor
>             Fix For: 4.1
>
>         Attachments: HTTPCLIENT-829.patch, HttpClient_829.java
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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-190) ChunkedInputStream does not handle sockets with timeouts

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

Oleg Kalnichevski resolved HTTPCORE-190.
----------------------------------------

    Resolution: Fixed

Adam

I fixed the problem in SVN trunk. Would it be a big deal for you to re-test your application with the latest snapshot from SVN trunk?

Oleg

> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCORE-190
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-190
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>    Affects Versions: 4.0
>            Reporter: Adam Bryzak
>            Priority: Minor
>             Fix For: 4.1
>
>         Attachments: HTTPCLIENT-829.patch, HttpClient_829.java
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

-- 
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-190) ChunkedInputStream does not handle sockets with timeouts

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

Oleg Kalnichevski updated HTTPCORE-190:
---------------------------------------

         Priority: Minor  (was: Major)
    Fix Version/s: 4.1

I can confirm the bug. Thanks for the good test case.

Oleg

> ChunkedInputStream does not handle sockets with timeouts
> --------------------------------------------------------
>
>                 Key: HTTPCORE-190
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-190
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>    Affects Versions: 4.0
>            Reporter: Adam Bryzak
>            Priority: Minor
>             Fix For: 4.1
>
>         Attachments: HTTPCLIENT-829.patch, HttpClient_829.java
>
>
> ChunkedInputStream does not handle socket timeouts when reading data. If a socket timeout is received after finishing reading a chunk (including it's CRLF combination) and before reading the next chunk's length, the next call to read will attempt to re-read the CRLF, causing an IOException with the message "CRLF expected at end of chunk" to be thrown. I have only tested this with 3.0 but it doesn't appear to be fixed in 3.1 or any 4.0 from looking at the code.

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