[
https://issues.apache.org/jira/browse/HTTPCLIENT-2416?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18062568#comment-18062568
]
Benjamin Peterson commented on HTTPCLIENT-2416:
-----------------------------------------------
I'm using Java 25 with 8 CPUS. Here's what I see:
{code:}
$ java --version
openjdk 25.0.2 2026-01-20 LTS
OpenJDK Runtime Environment Zulu25.32+21-CA (build 25.0.2+10-LTS)
OpenJDK 64-Bit Server VM Zulu25.32+21-CA (build 25.0.2+10-LTS, mixed mode,
sharing)
$ java -cp slf4j-api-2.0.7.jar:httpclient5-5.6.jar:httpcore5-5.4.1.jar
HttpGetExample.java
=== Initial Connection Pool Stats ===
Available: 0
Leased: 0
Pending: 0
Max: 100
=== Starting 1000 parallel requests ===
=== Results ===
Total requests: 1000
Successful: 0
Failed: 980
=== Final Connection Pool Stats ===
Available: 0
Leased: 20
Pending: 706
Max: 100
{code}
> interrupts and timeouts may leak connections
> --------------------------------------------
>
> Key: HTTPCLIENT-2416
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2416
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Affects Versions: 5.6
> Reporter: Benjamin Peterson
> Priority: Major
> Attachments: HttpGetExample.java
>
>
> 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]