Skip to content

Commit

Permalink
Not use safeRelease(...) but release(...) to release non-readable hol…
Browse files Browse the repository at this point in the history
…ders to ensure we not mask errors.

Motivation:

AbstractChannel attempts to "filter" messages which are written [1]. A goal of this process is to copy from heap to direct if necessary. However implementations of this method [2][3] may translate a buffer with 0 readable bytes to EMPTY_BUFFER. This may mask a user error where an empty buffer is written but already released.

Modifications:

Replace safeRelease(...) with release(...) to ensure we propagate reference count issues.

Result:

Fixes [netty#7383]
  • Loading branch information
normanmaurer committed Dec 4, 2017
1 parent 95b02e4 commit 251bb1a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ protected final ByteBuf newDirectBuffer(ByteBuf buf) {
protected final ByteBuf newDirectBuffer(Object holder, ByteBuf buf) {
final int readableBytes = buf.readableBytes();
if (readableBytes == 0) {
ReferenceCountUtil.safeRelease(holder);
ReferenceCountUtil.release(holder);
return Unpooled.EMPTY_BUFFER;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ protected final ByteBuf newDirectBuffer(ByteBuf buf) {
protected final ByteBuf newDirectBuffer(Object holder, ByteBuf buf) {
final int readableBytes = buf.readableBytes();
if (readableBytes == 0) {
ReferenceCountUtil.safeRelease(holder);
ReferenceCountUtil.release(holder);
return Unpooled.EMPTY_BUFFER;
}

Expand Down

0 comments on commit 251bb1a

Please sign in to comment.