szetszwo commented on code in PR #1481:
URL: https://github.com/apache/ratis/pull/1481#discussion_r3456330005


##########
ratis-netty/src/main/java/org/apache/ratis/netty/client/NettyClientStreamRpc.java:
##########
@@ -358,15 +364,40 @@ public void channelRead(ChannelHandlerContext ctx, Object 
msg) {
           LOG.error("{}: unexpected message {}", name, msg.getClass());
           return;
         }
-        try (DataStreamReplyByteBuf reply = (DataStreamReplyByteBuf) msg) {
-          process(reply);
+        final DataStreamReplyByteBuf reply = (DataStreamReplyByteBuf) msg;
+        final ReferenceCountedObject<DataStreamReply> ref = 
ReferenceCountedObject.<DataStreamReply>newBuilder()
+            .setValue((DataStreamReplyByteBuf) msg)
+            .setReleaseMethod(r -> {
+              if (r != null) {
+                Preconditions.assertSame(reply, r, "reply");
+                reply.release();
+              }
+            }).build();

Review Comment:
   Oops, this actually is not working.  Need to keep check not null first.
   ```java
      .setReleaseMethod(r -> {
                 if (r != null) {
                   Preconditions.assertSame(reply, r, "reply");
                   reply.release();
                 }
               }).build();
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to