History | Log In     View a printable version of the current page. Get help!  
Issue Details [XML]

Key: SES-656
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Arjohn Kampman
Reporter: Alex Vigdor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Sesame

HTTPClient does not respond appropriately when thread is interrupted

Created: 22/Dec/08 07:28 PM   Updated: 04/Jun/09 08:24 AM
Component/s: HTTPRepository
Affects Version/s: 2.2.1, 2.2.2, 2.2.3, 2.2.4
Fix Version/s: 2.3-pr1

File Attachments: 1. Text File HTTPClient.patch (1 kb)



 Description   
In attempting to build a UI that allows a user to cancel a long running task (e.g. replicating a large repository using HTTP connections), I discovered a flaw in the HTTPClient; it's releaseConnection() method attempts to consume the remaining response body, which can take many minutes if the thread was interrupted during a large query response. I've attached a patch for releaseConnection() that checks if the current thread is interrupted; if so, it calls method.abort(), which returns promptly, sacrificing the reusable connection, otherwise it uses the existing logic to ensure the connection can be reused.

 All   Comments   Change History      Sort Order:
Comment by Arjohn Kampman [16/Jan/09 09:07 AM]
Scheduling for 2.2.4.

Comment by Arjohn Kampman [04/Feb/09 12:13 PM]
Instead of checking for the interrupted status, HTTPClient no longer tries to read any remaining bytes from the response stream. All example code seems to indicate that simply calling method.releaseConnection() is the appropriate way to deal with connections.

Comment by Arjohn Kampman [10/Feb/09 09:56 AM]
"I've reopened this because the offered solution doesn't fix the behavior - the releaseConnection method of the underlying commons HTTPMethod also attempts to read the remaining bytes in the connection. Using abort() as I originally suggested, when the thread is interrupted, is appropriate use of the commons HTTP API in this situation." -- Alex Vigdor

Comment by Arjohn Kampman [10/Feb/09 10:00 AM]
The isInterrupted() check has been added to HTTPClient.