From 785ca67e46c762ed0ffaeda1e26e5f90276181e8 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Mon, 1 Dec 2025 12:30:02 +0000 Subject: [PATCH] 8372409: java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java timed out during warmup Reviewed-by: djelinski --- .../internal/net/http/Http3Connection.java | 23 ++++++++++++++++++- .../H3MultipleConnectionsToSameHost.java | 8 +++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http3Connection.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http3Connection.java index 17f230f3b15..6bf1b9184f8 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http3Connection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http3Connection.java @@ -561,7 +561,28 @@ public final class Http3Connection implements AutoCloseable { if (debug.on()) debug.log("Reference h3 stream: " + streamId); client.client.h3StreamReference(); exchanges.put(streamId, exchange); - exchange.start(); + // It's possible that the connection will have been closed + // by the time we reach here. + // We need to double-check that the connection is still opened + // after having put the exchange to the exchanges map. + if (isOpen()) { + // only start the exchange if the connection is + // still open + exchange.start(); + } else { + // Otherwise mark the exchange as unprocessed since we haven't + // sent the headers yet and the connection got closed + // before we started the exchange. + TerminationCause tc = quicConnection.terminationCause(); + if (Log.http3()) { + Log.logHttp3("HTTP/3 exchange for {0}/streamId={1} unprocessed due to {2}", + quicConnectionTag(), Long.toString(streamId), tc.getCloseCause()); + } + exchange.exchange.markUnprocessedByPeer(); + exchange.cancelImpl(tc.getCloseCause(), + Http3Error.fromCode(tc.getCloseCode()).orElse(H3_NO_ERROR)); + } + // OK to return the exchange even if already closed return exchange; } diff --git a/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java b/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java index 34d5163760f..862ccf22ddc 100644 --- a/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java +++ b/test/jdk/java/net/httpclient/http3/H3MultipleConnectionsToSameHost.java @@ -23,7 +23,7 @@ /* * @test id=with-continuations - * @bug 8087112 + * @bug 8087112 8372409 * @requires os.family != "windows" | ( os.name != "Windows 10" & os.name != "Windows Server 2016" * & os.name != "Windows Server 2019" ) * @library /test/lib /test/jdk/java/net/httpclient/lib @@ -46,7 +46,7 @@ */ /* * @test id=without-continuations - * @bug 8087112 + * @bug 8087112 8372409 * @requires os.family == "windows" & ( os.name == "Windows 10" | os.name == "Windows Server 2016" * | os.name == "Windows Server 2019" ) * @library /test/lib /test/jdk/java/net/httpclient/lib @@ -71,7 +71,7 @@ */ /* * @test id=useNioSelector - * @bug 8087112 + * @bug 8087112 8372409 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer @@ -96,7 +96,7 @@ */ /* * @test id=reno-cc - * @bug 8087112 + * @bug 8087112 8372409 * @library /test/lib /test/jdk/java/net/httpclient/lib * @build jdk.test.lib.net.SimpleSSLContext * jdk.httpclient.test.lib.http2.Http2TestServer