diff --git a/build.gradle b/build.gradle index 3e6958e4e7..a589405dcc 100644 --- a/build.gradle +++ b/build.gradle @@ -274,11 +274,8 @@ subprojects { onOutput { descriptor, event -> def evMsg = event.message - if (evMsg.contains("ResourceLeakDetector")) { - if (!evMsg.contains(" -Dio.netty.leakDetection") - && !evMsg.contains("DEBUG io.netty.util.ResourceLeakDetectorFactory")) { - logger.error("ERROR: Test: " + descriptor + " produced resource leak: " + event.message) - } + if (evMsg.contains("LoggingLeakCallback")) { + logger.error("ERROR: Test: " + descriptor + " produced resource leak: " + event.message) } } } diff --git a/reactor-netty5-http/src/main/java/reactor/netty5/http/client/HttpClientOperations.java b/reactor-netty5-http/src/main/java/reactor/netty5/http/client/HttpClientOperations.java index 15e57020df..b521a321f3 100644 --- a/reactor-netty5-http/src/main/java/reactor/netty5/http/client/HttpClientOperations.java +++ b/reactor-netty5-http/src/main/java/reactor/netty5/http/client/HttpClientOperations.java @@ -646,7 +646,7 @@ protected void onInboundNext(ChannelHandlerContext ctx, Object msg) { if (log.isDebugEnabled()) { log.debug(format(channel(), "Received last HTTP packet")); } - if (!(msg instanceof EmptyLastHttpContent)) { + if (!(msg instanceof EmptyLastHttpContent emptyLastHttpContent)) { if (redirecting != null) { Resource.dispose(msg); } @@ -654,6 +654,9 @@ protected void onInboundNext(ChannelHandlerContext ctx, Object msg) { super.onInboundNext(ctx, msg); } } + else { + emptyLastHttpContent.close(); + } if (redirecting == null) { // EmitResult is ignored as it is guaranteed that there will be only one emission of LastHttpContent diff --git a/reactor-netty5-http/src/main/java/reactor/netty5/http/server/HttpServerOperations.java b/reactor-netty5-http/src/main/java/reactor/netty5/http/server/HttpServerOperations.java index 34a494492d..afaca0315e 100644 --- a/reactor-netty5-http/src/main/java/reactor/netty5/http/server/HttpServerOperations.java +++ b/reactor-netty5-http/src/main/java/reactor/netty5/http/server/HttpServerOperations.java @@ -576,9 +576,12 @@ protected void onInboundNext(ChannelHandlerContext ctx, Object msg) { return; } if (msg instanceof HttpContent) { - if (!(msg instanceof EmptyLastHttpContent)) { + if (!(msg instanceof EmptyLastHttpContent emptyLastHttpContent)) { super.onInboundNext(ctx, msg); } + else { + emptyLastHttpContent.close(); + } if (msg instanceof LastHttpContent) { //force auto read to enable more accurate close selection now inbound is done channel().setOption(ChannelOption.AUTO_READ, true); diff --git a/reactor-netty5-http/src/test/java/reactor/netty5/http/client/HttpClientOperationsTest.java b/reactor-netty5-http/src/test/java/reactor/netty5/http/client/HttpClientOperationsTest.java index ecfae78d0f..d4a5c4f36a 100644 --- a/reactor-netty5-http/src/test/java/reactor/netty5/http/client/HttpClientOperationsTest.java +++ b/reactor-netty5-http/src/test/java/reactor/netty5/http/client/HttpClientOperationsTest.java @@ -172,7 +172,10 @@ private void doTestStatus(HttpResponseStatus status) { HttpClientOperations ops = new HttpClientOperations(() -> channel, ConnectionObserver.emptyListener(), ClientCookieEncoder.STRICT, ClientCookieDecoder.STRICT); - ops.setNettyResponse(new DefaultFullHttpResponse(HTTP_1_1, status, channel.bufferAllocator().allocate(0))); - assertThat(ops.status().reasonPhrase()).isEqualTo(status.reasonPhrase()); + try (DefaultFullHttpResponse response = + new DefaultFullHttpResponse(HTTP_1_1, status, channel.bufferAllocator().allocate(0))) { + ops.setNettyResponse(response); + assertThat(ops.status().reasonPhrase()).isEqualTo(status.reasonPhrase()); + } } }