Skip to content

Commit

Permalink
DRILL-8489: Sender memory leak when rpc encode exception (apache#2901)
Browse files Browse the repository at this point in the history
  • Loading branch information
shfshihuafeng authored and jnturton committed May 12, 2024
1 parent 28f603f commit f33e14a
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected void encode(ChannelHandlerContext ctx, OutboundRpcMessage msg, List<Ob
msg.release();
return;
}

boolean encodeSucess = false;
try{
if (RpcConstants.EXTRA_DEBUGGING) {
logger.debug("Encoding outbound message {}", msg);
Expand Down Expand Up @@ -131,9 +131,13 @@ protected void encode(ChannelHandlerContext ctx, OutboundRpcMessage msg, List<Ob
if (RpcConstants.EXTRA_DEBUGGING) {
logger.debug("Sent message. Ending writer index was {}.", buf.writerIndex());
}
encodeSucess = true;
} finally {
// make sure to release Rpc Messages underlying byte buffers.
//msg.release();
//if msg instanceof ReferenceCounted,netty can release msg.
if (!encodeSucess) {
msg.release();
}
}
}

Expand Down

0 comments on commit f33e14a

Please sign in to comment.