diff --git a/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/HttpStreamOverHTTP3.java b/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/HttpStreamOverHTTP3.java index f05904f85f4..5c987f1ba30 100644 --- a/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/HttpStreamOverHTTP3.java +++ b/jetty-core/jetty-http3/jetty-http3-server/src/main/java/org/eclipse/jetty/http3/server/internal/HttpStreamOverHTTP3.java @@ -528,6 +528,12 @@ public class HttpStreamOverHTTP3 implements HttpStream public Runnable onFailure(Throwable failure) { + try (AutoLock ignored = lock.lock()) + { + if (chunk != null) + chunk.release(); + chunk = Content.Chunk.from(failure, true); + } return httpChannel.onFailure(failure); } } diff --git a/jetty-core/jetty-quic/jetty-quic-quiche/jetty-quic-quiche-foreign-incubator/src/main/java/org/eclipse/jetty/quic/quiche/foreign/incubator/ForeignIncubatorQuicheConnection.java b/jetty-core/jetty-quic/jetty-quic-quiche/jetty-quic-quiche-foreign-incubator/src/main/java/org/eclipse/jetty/quic/quiche/foreign/incubator/ForeignIncubatorQuicheConnection.java index 81cdc91ffe3..5eccafcb14a 100644 --- a/jetty-core/jetty-quic/jetty-quic-quiche/jetty-quic-quiche-foreign-incubator/src/main/java/org/eclipse/jetty/quic/quiche/foreign/incubator/ForeignIncubatorQuicheConnection.java +++ b/jetty-core/jetty-quic/jetty-quic-quiche/jetty-quic-quiche-foreign-incubator/src/main/java/org/eclipse/jetty/quic/quiche/foreign/incubator/ForeignIncubatorQuicheConnection.java @@ -879,7 +879,7 @@ public class ForeignIncubatorQuicheConnection extends QuicheConnection try (AutoLock ignore = lock.lock()) { if (quicheConn == null) - return -1; + throw new IOException("connection was released"); long read; try (ResourceScope scope = ResourceScope.newConfinedScope()) @@ -905,15 +905,10 @@ public class ForeignIncubatorQuicheConnection extends QuicheConnection } } + if (read == quiche_error.QUICHE_ERR_DONE) + return isStreamFinished(streamId) ? -1 : 0; if (read < 0L) - { - if (isStreamFinished(streamId)) - return -1; - else if (read == quiche_error.QUICHE_ERR_DONE) - return 0; - else - throw new IOException("failed to read from stream " + streamId + "; quiche_err=" + quiche_error.errToString(read)); - } + throw new IOException("failed to read from stream " + streamId + "; quiche_err=" + quiche_error.errToString(read)); buffer.position((int)(buffer.position() + read)); return (int)read; } diff --git a/jetty-core/jetty-quic/jetty-quic-quiche/jetty-quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/JnaQuicheConnection.java b/jetty-core/jetty-quic/jetty-quic-quiche/jetty-quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/JnaQuicheConnection.java index 289923dafab..39669ef1553 100644 --- a/jetty-core/jetty-quic/jetty-quic-quiche/jetty-quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/JnaQuicheConnection.java +++ b/jetty-core/jetty-quic/jetty-quic-quiche/jetty-quic-quiche-jna/src/main/java/org/eclipse/jetty/quic/quiche/jna/JnaQuicheConnection.java @@ -705,18 +705,13 @@ public class JnaQuicheConnection extends QuicheConnection try (AutoLock ignore = lock.lock()) { if (quicheConn == null) - return -1; + throw new IOException("connection was released"); bool_pointer fin = new bool_pointer(); int read = LibQuiche.INSTANCE.quiche_conn_stream_recv(quicheConn, new uint64_t(streamId), buffer, new size_t(buffer.remaining()), fin).intValue(); + if (read == quiche_error.QUICHE_ERR_DONE) + return isStreamFinished(streamId) ? -1 : 0; if (read < 0L) - { - if (isStreamFinished(streamId)) - return -1; - else if (read == quiche_error.QUICHE_ERR_DONE) - return 0; - else - throw new IOException("failed to read from stream " + streamId + "; quiche_err=" + quiche_error.errToString(read)); - } + throw new IOException("failed to read from stream " + streamId + "; quiche_err=" + quiche_error.errToString(read)); buffer.position(buffer.position() + read); return read; } diff --git a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientStreamTest.java b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientStreamTest.java index 228a2eeec5d..c68d865c7e5 100644 --- a/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientStreamTest.java +++ b/jetty-core/jetty-tests/jetty-test-client-transports/src/test/java/org/eclipse/jetty/test/client/transport/HttpClientStreamTest.java @@ -1202,8 +1202,9 @@ public class HttpClientStreamTest extends AbstractTest @MethodSource("transports") @Tag("DisableLeakTracking:server:H2") @Tag("DisableLeakTracking:server:H2C") + @Tag("DisableLeakTracking:server:H3") @Tag("DisableLeakTracking:server:FCGI") - public void testHttpStreamConsumeAvailableUponClientTimeout(Transport transport) throws Exception + public void testHttpStreamConsumeAvailableUponClientAbort(Transport transport) throws Exception { AtomicReference clientRequestRef = new AtomicReference<>();