You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by yo...@apache.org on 2022/06/13 07:37:52 UTC

[bookkeeper] 02/02: Fix the V2 AddRequest object leak issue (#3323)

This is an automated email from the ASF dual-hosted git repository.

yong pushed a commit to branch branch-4.14
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git

commit 5370d63391e5683d27ac9c4f4166281eaf026a10
Author: Yong Zhang <zh...@gmail.com>
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)
---
 .../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;
         }