From beaad129f598949a6d627bf054832aeda29e5afc Mon Sep 17 00:00:00 2001 From: Armin Date: Wed, 1 Nov 2017 20:01:23 +0100 Subject: [PATCH 1/2] BUG: Fixed ByteBuf leaking in org.elasticsearch.http.netty4.Netty4HttpRequestHandler#channelRead0 --- .../http/netty4/Netty4HttpRequestHandler.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequestHandler.java b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequestHandler.java index b31c412920aa1..63c53434969f0 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequestHandler.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequestHandler.java @@ -64,7 +64,13 @@ protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Except Unpooled.copiedBuffer(request.content()), request.headers(), request.trailingHeaders()); - final Netty4HttpRequest httpRequest = new Netty4HttpRequest(serverTransport.xContentRegistry, copy, ctx.channel()); + final Netty4HttpRequest httpRequest; + try { + httpRequest = new Netty4HttpRequest(serverTransport.xContentRegistry, copy, ctx.channel()); + } catch (Exception ex) { + request.release(); + throw ex; + } final Netty4HttpChannel channel = new Netty4HttpChannel(serverTransport, httpRequest, pipelinedRequest, detailedErrorsEnabled, threadContext); From cddbb395cb3f03da06e6056361c79a357d3ff507 Mon Sep 17 00:00:00 2001 From: Armin Date: Thu, 2 Nov 2017 14:18:22 +0100 Subject: [PATCH 2/2] only release for HttpPipelinedRequest --- .../elasticsearch/http/netty4/Netty4HttpRequestHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequestHandler.java b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequestHandler.java index 63c53434969f0..6da0f5433bae6 100644 --- a/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequestHandler.java +++ b/modules/transport-netty4/src/main/java/org/elasticsearch/http/netty4/Netty4HttpRequestHandler.java @@ -68,7 +68,9 @@ protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Except try { httpRequest = new Netty4HttpRequest(serverTransport.xContentRegistry, copy, ctx.channel()); } catch (Exception ex) { - request.release(); + if (pipelinedRequest != null) { + pipelinedRequest.release(); + } throw ex; } final Netty4HttpChannel channel =