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 committed by GitHub
parent 299a682d3f
commit 1f4b9e36ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,8 +110,8 @@ public class HttpToHttp2ConnectionHandler extends Http2ConnectionHandler {
// Write the data // Write the data
final ByteBuf content = ((HttpContent) msg).content(); final ByteBuf content = ((HttpContent) msg).content();
endStream = isLastContent && trailers.isEmpty(); endStream = isLastContent && trailers.isEmpty();
release = false;
encoder.writeData(ctx, currentStreamId, content, 0, endStream, promiseAggregator.newPromise()); encoder.writeData(ctx, currentStreamId, content, 0, endStream, promiseAggregator.newPromise());
release = false;
if (!trailers.isEmpty()) { if (!trailers.isEmpty()) {
// Write trailing headers. // Write trailing headers.