RFR: 8326498: java.net.http.HttpClient connection leak using http/2 [v11]
Daniel Jeliński
djelinski at openjdk.org
Mon Nov 24 10:09:25 UTC 2025
On Fri, 21 Nov 2025 01:17:37 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
>> Can I please get a review for this fix which addresses a connection leak in HttpClient when dealing with HTTP/2 requests?
>>
>> I have added a comment in https://bugs.openjdk.org/browse/JDK-8326498 which explains what the issue is. The fix here addresses the issue by cleaning up the `Http2Connection` closing logic and centralizing it to a connection terminator. The terminator then ensures that the right resources are closed (including the underlying SocketChannel) when the termination happens.
>>
>> A new jtreg test has been introduced which reproduces the issue and verifies the fix.
>
> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
>
> use ClosedChannelException instead of IOException
Marked as reviewed by djelinski (Reviewer).
src/java.net.http/share/classes/jdk/internal/net/http/Http2TerminationCause.java line 268:
> 266: private static final class InternalError extends Http2TerminationCause {
> 267: private InternalError(final Throwable cause) {
> 268: super(ErrorFrame.INTERNAL_ERROR, new Exception(cause));
why do we need to wrap the throwable here?
test/jdk/java/net/httpclient/http2/BurstyRequestsTest.java line 128:
> 126: final Set<?> openedConnections = HttpClientImplAccess.getOpenedConnections(client);
> 127: assumeTrue(openedConnections != null,
> 128: "skipping test against HttpClient of type " + client.getClass().getName());
Please remove. The HttpClient will always be of the expected type, and keeping this code around will only make it harder to spot when the assumption no longer holds.
-------------
PR Review: https://git.openjdk.org/jdk/pull/28233#pullrequestreview-3499234926
PR Review Comment: https://git.openjdk.org/jdk/pull/28233#discussion_r2555375656
PR Review Comment: https://git.openjdk.org/jdk/pull/28233#discussion_r2555528331
More information about the net-dev
mailing list