diff --git a/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/ConnectionCloseHeaderHandlingTest.java b/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/ConnectionCloseHeaderHandlingTest.java index fc0082d8d1..91fceaa81c 100644 --- a/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/ConnectionCloseHeaderHandlingTest.java +++ b/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/ConnectionCloseHeaderHandlingTest.java @@ -18,6 +18,7 @@ import io.servicetalk.buffer.api.Buffer; import io.servicetalk.concurrent.BlockingIterator; import io.servicetalk.concurrent.api.Completable; +import io.servicetalk.concurrent.api.CompositeCloseable; import io.servicetalk.http.api.HttpPayloadWriter; import io.servicetalk.http.api.HttpServerBuilder; import io.servicetalk.http.api.ReservedStreamingHttpConnection; @@ -132,7 +133,7 @@ void setUp(boolean useUds, boolean viaProxy, boolean awaitRequestPayload) throws HttpServers.forAddress(localAddress(0))) .ioExecutor(serverCtx.ioExecutor()) .executor(serverCtx.executor()) - .enableWireLogging("servicetalk-tests-wire-logger", TRACE, Boolean.TRUE::booleanValue) + .enableWireLogging("servicetalk-tests-wire-logger", TRACE, () -> true) .appendConnectionAcceptorFilter(original -> new DelegatingConnectionAcceptor(original) { @Override public Completable accept(final ConnectionContext context) { @@ -216,7 +217,17 @@ public Completable accept(final ConnectionContext context) { @AfterEach void tearDown() throws Exception { try { - newCompositeCloseable().appendAll(connection, client, serverContext).close(); + CompositeCloseable closeable = newCompositeCloseable(); + if (connection != null) { + closeable.append(connection); + } + if (client != null) { + closeable.append(client); + } + if (serverContext != null) { + closeable.append(serverContext); + } + closeable.close(); } finally { if (proxyTunnel != null) { safeClose(proxyTunnel); @@ -392,7 +403,9 @@ void serverCloseSecondPipelinedRequestWriteAborted(boolean useUds, boolean viaPr String content = "request_content"; connection.request(connection.get("/second") .addHeader(CONTENT_LENGTH, valueOf(content.length())) - .payloadBody(from(content).concat(never()), RAW_STRING_SERIALIZER)) + // Write only part of the intended payload body to simulate incomplete request: + .payloadBody(from(content.substring(0, content.length() / 2)).concat(never()), + RAW_STRING_SERIALIZER)) .whenOnError(secondRequestError::set) .whenFinally(secondResponseReceived::countDown) .subscribe(second -> { });