This is an automated email from the ASF dual-hosted git repository.
yong pushed a commit to branch branch-4.15
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/branch-4.15 by this push:
new 797b575022 Fix the V2 AddRequest object leak issue (#3323)
797b575022 is described below
commit 797b57502278a70095ed4c6ed6178e7afbf4d0a4
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)
---
.../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 35c3c5fb11..169307123c 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;
}