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
This commit is contained in:
Norman Maurer 2019-09-26 21:59:57 +02:00
parent 6f584ec9de
commit 8f23e27bd2

View File

@ -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.