This is an automated email from the ASF dual-hosted git repository. nicoloboschi pushed a commit to branch ds-4.14 in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
commit 177067907e58e678926aec56d94b94b6c9272d37 Author: Yong Zhang <[email protected]> AuthorDate: Mon Jun 13 15:27:51 2022 +0800 Fix the V2 AddRequest object leak issue (#3323) --- **Motivation** If the request is a V2 add request, we retained the data's reference when creating the AddRequest object. To avoid the object leak, we need to release the reference if we met any errors before sending it. (cherry picked from commit f887f8d7a507800b71b4143a40b0e45902f5f170) (cherry picked from commit 5370d63391e5683d27ac9c4f4166281eaf026a10) --- .../java/org/apache/bookkeeper/proto/PerChannelBookieClient.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java index 12209a636d..aeef8f8e19 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PerChannelBookieClient.java @@ -1127,6 +1127,14 @@ public class PerChannelBookieClient extends ChannelInboundHandlerAdapter { StringUtils.requestToString(request)); errorOut(key, BKException.Code.TooManyRequestsException); + + // If the request is a V2 add request, we retained the data's reference when creating the AddRequest + // object. To avoid the object leak, we need to release the reference if we met any errors + // before sending it. + if (request instanceof BookieProtocol.AddRequest) { + BookieProtocol.AddRequest ar = (BookieProtocol.AddRequest) request; + ar.recycle(); + } return; }
