HttpPostRequestEncoder may return a slice which is not retained.

Motivation:

We miss to retain a slice before return it to the user and so an reference count error may accour later on.

Modifications:

Use readRetainedSlice(...) and so ensure we retain the buffer before hand it of to the user.

Result:

Fixes [#6626].
This commit is contained in:
Norman Maurer 2017-04-18 06:44:44 +02:00
parent 1b0b8f80cd
commit fb113dce3a

View File

@ -894,9 +894,7 @@ public class HttpPostRequestEncoder implements ChunkedInput<HttpContent> {
private ByteBuf fillByteBuf() {
int length = currentBuffer.readableBytes();
if (length > HttpPostBodyUtil.chunkSize) {
ByteBuf slice = currentBuffer.slice(currentBuffer.readerIndex(), HttpPostBodyUtil.chunkSize);
currentBuffer.skipBytes(HttpPostBodyUtil.chunkSize);
return slice;
return currentBuffer.readRetainedSlice(HttpPostBodyUtil.chunkSize);
} else {
// to continue
ByteBuf slice = currentBuffer;