diff --git a/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientQuicConnection.java b/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientQuicConnection.java index 5ab6d1c1ea1..4270390633c 100644 --- a/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientQuicConnection.java +++ b/jetty-http3/http3-client/src/main/java/org/eclipse/jetty/http3/client/ClientQuicConnection.java @@ -28,6 +28,7 @@ import org.eclipse.jetty.http3.quiche.QuicheConnectionId; import org.eclipse.jetty.io.ByteBufferPool; import org.eclipse.jetty.io.EndPoint; import org.eclipse.jetty.io.RuntimeIOException; +import org.eclipse.jetty.util.Promise; import org.eclipse.jetty.util.thread.Scheduler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,6 +69,20 @@ public class ClientQuicConnection extends QuicConnection fillInterested(); } + @Override + protected void onClose(QuicheConnectionId quicheConnectionId, QuicSession session) + { + super.onClose(quicheConnectionId, session); + + InetSocketAddress remoteAddress = session.getRemoteAddress(); + if (pendingSessions.remove(remoteAddress) != null) + { + Promise promise = (Promise)context.get(ClientQuicConnector.CONNECTION_PROMISE_CONTEXT_KEY); + if (promise != null) + promise.failed(new IOException("QUIC connection refused")); + } + } + @Override protected QuicSession createSession(InetSocketAddress remoteAddress, ByteBuffer cipherBuffer) { diff --git a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicConnection.java b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicConnection.java index fd5b4f2526b..fd2c85025db 100644 --- a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicConnection.java +++ b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicConnection.java @@ -68,7 +68,7 @@ public abstract class QuicConnection extends AbstractConnection return quicheConfig; } - protected void onClose(QuicheConnectionId quicheConnectionId) + protected void onClose(QuicheConnectionId quicheConnectionId, QuicSession session) { if (quicheConnectionId != null) sessions.remove(quicheConnectionId); diff --git a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicSession.java b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicSession.java index 009951e8372..74141296deb 100644 --- a/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicSession.java +++ b/jetty-http3/http3-common/src/main/java/org/eclipse/jetty/http3/common/QuicSession.java @@ -239,7 +239,7 @@ public abstract class QuicSession endpoints.values().forEach(AbstractEndPoint::close); endpoints.clear(); flusher.close(); - connection.onClose(quicheConnectionId); + connection.onClose(quicheConnectionId, this); LifeCycle.stop(strategy); } finally