Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0395542

Browse files
committed
Ensure BufUtil.release() is called even if writeBytes() fails in writeAndRelease()
1 parent 015e60b commit 0395542

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

codec/src/main/java/io/netty/handler/codec/OutputMessageBuf.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,10 @@ public boolean drainToNextOutbound(ChannelHandlerContext ctx) {
167167
}
168168

169169
private static void writeAndRelease(ByteBuf dst, ByteBuf src) {
170-
dst.writeBytes(src, src.readerIndex(), src.readableBytes());
171-
BufUtil.release(src);
170+
try {
171+
dst.writeBytes(src, src.readerIndex(), src.readableBytes());
172+
} finally {
173+
BufUtil.release(src);
174+
}
172175
}
173176
}

0 commit comments

Comments
 (0)