RFR: 8326498: java.net.http.HttpClient connection leak using http/2 [v10]

Daniel Fuchs dfuchs at openjdk.org
Thu Nov 20 14:44:03 UTC 2025


On Thu, 20 Nov 2025 14:01:32 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:
> 
>   introduce HttpClientImplAccess instead of using Http3ConnectionAccess

src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java line 2116:

> 2114:                 // that way when Http2Connection.isOpen() returns false in that situation, then this
> 2115:                 // getTerminationCause() will return a termination cause.
> 2116:                 terminate(Http2TerminationCause.forException(new IOException("channel is not open")));

Shouldn't we use `new ClosedChannelException()` here instead of `new IOException("channel is not open")`

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28233#discussion_r2546322746


More information about the net-dev mailing list