You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Archie Cobbs (JIRA)" <ji...@apache.org> on 2008/01/24 18:12:34 UTC
[jira] Created: (HTTPCLIENT-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
--------------------------------------------------------------------------------------
Key: HTTPCLIENT-731
URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
Project: HttpComponents HttpClient
Issue Type: Improvement
Components: HttpClient
Affects Versions: 3.1 Final
Reporter: Archie Cobbs
Consider this logic in {{TimeoutController.java}}:
{noformat}
public static void execute(Thread task, long timeout) throws TimeoutException {
task.start();
try {
task.join(timeout);
} catch (InterruptedException e) {
/* if somebody interrupts us he knows what he is doing */
}
if (task.isAlive()) {
task.interrupt();
throw new TimeoutException();
}
}
{noformat}
The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Oleg Kalnichevski (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562456#action_12562456 ]
Oleg Kalnichevski commented on HTTPCLIENT-731:
----------------------------------------------
Archie,
(1) There is a reference to a Java 1.4 method which breaks Java 1.2.2 compatibility required for Httpclient 3.x codeline
(2) Unfortunately you cannot add another exception declaration to a public method as this breaks backward API compatibility.
Why are you using ControllerThreadSocketFactory in the first place?
Oleg
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
> Attachments: HTTPCLIENT-731.2.txt, HTTPCLIENT-731.txt
>
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Archie Cobbs (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Archie Cobbs updated HTTPCLIENT-731:
------------------------------------
Attachment: HTTPCLIENT-731.txt
Attaching a patch for this bug that fixes the basic problem, i.e., the bogus conversion of InterruptedException into connection timeout. Instead, we convert it into an IOException.
This was just the minimal work needed to work around my problem. More thought and better design is probably needed. However, this patch by itself does represent an improvement to the current state I think.
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
> Attachments: HTTPCLIENT-731.txt
>
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Archie Cobbs (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562224#action_12562224 ]
Archie Cobbs commented on HTTPCLIENT-731:
-----------------------------------------
Good point. To fix this, there should be a call to "task.interrupt()" just before the new IOException is created (in both places), e.g.:
} catch (InterruptedException e) {
task.interrupt();
throw (IOException)new IOException("thread interrupted").initCause(e);
}
This will preserve the previous behavior with respect to the supervised thread. Thanks.
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
> Attachments: HTTPCLIENT-731.txt
>
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Ortwin Glück (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562220#action_12562220 ]
Ortwin Glück commented on HTTPCLIENT-731:
-----------------------------------------
But this way the supervised thread is not interrupted, when you interrupt the supervising thread. That may be lead to leaks.
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
> Attachments: HTTPCLIENT-731.txt
>
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Archie Cobbs (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562714#action_12562714 ]
Archie Cobbs commented on HTTPCLIENT-731:
-----------------------------------------
If this stuff is addressed in 4.0 that's fine with me. I was only trying to bring attention to the issue but it sounds like it's already being addressed in which case feel free to close out this bug.
I have worked around the problem in my own code so there's no urgency for a 3.x fix on my part.
My only general big picture comments:
- It would be nice if Thread.interrupt() could be used by any part of an application to abort an in-progress HTTP request. Some applications use Thread.interrupt() as a general "stop what you're doing" mechanism (for better or worse) when there are blocking tasks involved. Of course this means methods declaring 'throws InterruptedException', etc. I'm sure this feature is debatable.
- What happens in response to a Thread.interrupt(), whatever that is, should be documented.
Thanks!
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
> Attachments: HTTPCLIENT-731.2.txt, HTTPCLIENT-731.txt
>
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Roland Weber (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562634#action_12562634 ]
Roland Weber commented on HTTPCLIENT-731:
-----------------------------------------
Hello Archie,
support for interrupts is lacking in HttpClient 3.1 connection management all over the place. We don't have an InterruptedException in the connection manager interface, so we are mapping those exceptions to timeout exceptions. Have a look at HTTPCLIENT-633 to learn of another case.
HttpClient 3.1 is in maintenance mode, bug fixes only. Screwed design is bad, but not a bug. Documenting the behavior is a good idea, but I don't see a point in trying to change it. The issues of HTTPCLIENT-633 are already fixed in HttpClient 4.0 trunk and iirc the TimeoutController was a workaround for implementing connection timeouts on 1.2 JVMs which is no longer needed in the new codebase. Actually, it is not even needed in the old codebase if you're on Java 1.4 or later. There is some reflection magic that should use the timeout threads only when there is no Socket constructor that supports timeouts:
http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.html#createSocket(java.lang.String,%20int,%20java.net.InetAddress,%20int,%20org.apache.commons.httpclient.params.HttpConnectionParams)
I fail to see why converting an interrupt to an IOException is less bogus than converting it to a TimeoutException. Would it help you if the TimeoutException had a "thread interrupted" message that you could check for?
cheers,
Roland
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
> Attachments: HTTPCLIENT-731.2.txt, HTTPCLIENT-731.txt
>
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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: (HTTPCLIENT-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Roland Weber (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Roland Weber closed HTTPCLIENT-731.
-----------------------------------
Resolution: Won't Fix
Hello Archie,
I hope that 4.0 will satisfy your requirements. If it doesn't, feel free to open new issues.
The ClientConnectionManager does declare InterruptedException for all blocking operations:
http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/conn/ClientConnectionManager.html#getConnection(org.apache.http.conn.HttpRoute)
Interrupts during normal IO operations should be mapped by JVM classes to InterruptedIOException:
http://java.sun.com/j2se/1.5.0/docs/api/java/io/InterruptedIOException.html
Funny to see that SocketTimeoutException is a subclass of InterruptedIOException :-)
Still, the preferred way to abort request execution in 4.0 is by calling request.abort():
http://hc.apache.org/httpcomponents-client/httpclient/apidocs/org/apache/http/client/methods/AbortableHttpRequest.html
I guess we'll have to add some thread interrupt mechanism there to abort if the request is blocked waiting for a connection.
cheers,
Roland
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
> Attachments: HTTPCLIENT-731.2.txt, HTTPCLIENT-731.txt
>
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Archie Cobbs (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562226#action_12562226 ]
Archie Cobbs commented on HTTPCLIENT-731:
-----------------------------------------
Bleh, forgot "task" is a Runnable, not a Thread. I'll attach a new patch shortly.
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
> Attachments: HTTPCLIENT-731.txt
>
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Archie Cobbs (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12562165#action_12562165 ]
Archie Cobbs commented on HTTPCLIENT-731:
-----------------------------------------
Actually on looking at this further, I don't think HttpMethodBase.abort() will do anything while the TCP connection is still being established (please correct me if I'm wrong).
So include in this request making the functioning and semantics of the abort() method "airtight". That is, abort() is never ignored (unless the method is already completed) and causes the request to truly abort as soon as possible.; throwing IOException as a result of abort()ing is fine.
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Archie Cobbs (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Archie Cobbs updated HTTPCLIENT-731:
------------------------------------
Attachment: HTTPCLIENT-731.2.txt
Attaching better version of patch. This patch also removes some unused code.
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
> Attachments: HTTPCLIENT-731.2.txt, HTTPCLIENT-731.txt
>
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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-731) Interrupting a connecting HTTP
request thread incorrectly becomes a timeout exception
Posted by "Archie Cobbs (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HTTPCLIENT-731?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Archie Cobbs updated HTTPCLIENT-731:
------------------------------------
Environment: Java 1.5 Linux
> Interrupting a connecting HTTP request thread incorrectly becomes a timeout exception
> --------------------------------------------------------------------------------------
>
> Key: HTTPCLIENT-731
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-731
> Project: HttpComponents HttpClient
> Issue Type: Improvement
> Components: HttpClient
> Affects Versions: 3.1 Final
> Environment: Java 1.5 Linux
> Reporter: Archie Cobbs
>
> Consider this logic in {{TimeoutController.java}}:
> {noformat}
> public static void execute(Thread task, long timeout) throws TimeoutException {
> task.start();
> try {
> task.join(timeout);
> } catch (InterruptedException e) {
> /* if somebody interrupts us he knows what he is doing */
> }
> if (task.isAlive()) {
> task.interrupt();
> throw new TimeoutException();
> }
> }
> {noformat}
> The effect of this is that if thread A is in the middle of performing an HTTP request and happens to be waiting for the socket to connect, and then thread B interrupts thread A, thread A will throw a {{TimeoutException}}, even if the actual timeout is far off in the future.
> In other words, interrupting a requesting thread that happens to be waiting for a socket to connect is incorrectly interpreted as a connection timeout, which is incorrect.
> In my application, this causes the client to incorrectly believe the server is down, when in actuality some other part of the client is simply trying to cancel an outstanding RPC request.
> I realize that invoking {{HttpMethodBase.abort()}} would be a better way to abort the RPC request and am working on refactoring my code to do that.
> However, this "translation" of a thread interruption into a timeout event is still incorrect. Furthermore, this behavior is undocumented AFAICT.
> Suggestion for improvement: Convert thread interruptions into the equivalent of {{abort()}} and document this behavior.
--
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