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:27:58 UTC

[bookkeeper] branch master updated: 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 master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new f887f8d7a5  Fix the V2 AddRequest object leak issue (#3323)
f887f8d7a5 is described below

commit f887f8d7a507800b71b4143a40b0e45902f5f170
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.
---
 .../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 f798e8001a..0592378731 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
@@ -1135,6 +1135,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;
         }