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


##########
ratis-netty/src/main/java/org/apache/ratis/netty/NettyRpcProxy.java:
##########
@@ -162,7 +162,26 @@ protected void initChannel(SocketChannel ch) {
     synchronized ChannelFuture offer(RaftNettyServerRequestProto request,
         CompletableFuture<RaftNettyServerReplyProto> reply) throws 
AlreadyClosedException {
       replies.offer(reply);
-      return client.writeAndFlush(request);
+      final ChannelFuture future;
+      try {
+        future = client.writeAndFlush(request);
+      } catch (AlreadyClosedException e) {
+        // Rollback: remove from queue since the request was never sent.
+        replies.remove(reply);
+        throw e;
+      }

Review Comment:
   Let's call client.writeAndFlush(..) first and then add the reply.



-- 
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