From 8f23e27bd2e25f03e3cd9710fc0105d748ec7a5a Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Thu, 26 Sep 2019 21:59:57 +0200 Subject: [PATCH] We should only disable releasing of the message once writeData(...) was called successfully (#9610) Motivation: At the moment we set release to false before we call writeData(...). This could let to the sitatuation that we will miss to release the message if writeData(...) throws. We should set release to false after we called writeData(...) to ensure the ownership of the buffer is correctly transferred. Modifications: - Set release to false after writeData(...) was successfully called only Result: No possibility for a buffer leak --- .../netty/handler/codec/http2/HttpToHttp2ConnectionHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandler.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandler.java index bfaef776d2..84998c2b44 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandler.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/HttpToHttp2ConnectionHandler.java @@ -110,8 +110,8 @@ public class HttpToHttp2ConnectionHandler extends Http2ConnectionHandler { // Write the data final ByteBuf content = ((HttpContent) msg).content(); endStream = isLastContent && trailers.isEmpty(); - release = false; encoder.writeData(ctx, currentStreamId, content, 0, endStream, promiseAggregator.newPromise()); + release = false; if (!trailers.isEmpty()) { // Write trailing headers.