[
https://issues.apache.org/jira/browse/HTTPCORE-795?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18064276#comment-18064276
]
Benjamin Peterson commented on HTTPCORE-795:
--------------------------------------------
I would like to understand the release problem better if you don't mind
elaborating. When I glanced at {{PoolingHttpClientConnectionManager.release}}
and {{StrictConnPool.release}}, I didn't see any operations that would be
interrupted.
Putting aside problems _releasing_ connections, I believe acquiring has a bug
very similar to the one that was just fixed with {{TimeoutException}}. Namely,
{{InterruptedException}} is thrown, the future is completed by the pool, and
the noop {{cancel()}} call in {{InternalExecRuntime}} leaks the acquired
connection.
> interrupts and timeouts may leak connections
> --------------------------------------------
>
> Key: HTTPCORE-795
> URL: https://issues.apache.org/jira/browse/HTTPCORE-795
> Project: HttpComponents HttpCore
> Issue Type: Bug
> Reporter: Benjamin Peterson
> Priority: Minor
> Fix For: 5.4.3, 5.5-alpha1
>
> Attachments: HttpGetExample.java, HttpGetExample2.java,
> TimeoutLeakExample.java
>
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> Consider {{InternalExecRuntime.acquireEndpoint}}:
> {code:java}
> try {
> final ConnectionEndpoint connectionEndpoint =
> connRequest.get(connectionRequestTimeout);
> } catch (final TimeoutException ex) {
> connRequest.cancel();
> throw new ConnectionRequestTimeoutException(ex.getMessage());
> } catch (final InterruptedException interrupted) {
> connRequest.cancel();
> Thread.currentThread().interrupt();
> throw new RequestFailedException("Request aborted",
> interrupted);
> }
> {code}
> Consider this order of operations:
> 1. The thread blocked in {{codeRequest.get}} is interrupted or times out.
> 2. The connection pool completes the future with a connection.
> 3. The interrupted thread starts propagating the {{InterruptedException}} or
> {{TimeoutException}}. When it reaches the {{catch}} blocks, it will call
> {{connRequest.cancel()}}. But cancelation will do nothing because the
> connection pool already completed the future. The connection will leak.
> The window may be narrow, but it's certainly a possibility if heavy load
> means the blocked thread is delayed in being scheduled to propagate the
> {{InterruptedException}} or {{TimeoutException}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]