Technoboy- commented on code in PR #15021:
URL: https://github.com/apache/pulsar/pull/15021#discussion_r841811812


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TransactionBufferHandlerImpl.java:
##########
@@ -154,17 +156,16 @@ public void endTxn(OpRequestSend op) {
             if (throwable == null) {
                 if (clientCnx.ctx().channel().isActive()) {
                     
clientCnx.registerTransactionBufferHandler(TransactionBufferHandlerImpl.this);
-                    outstandingRequests.put(op.requestId, op);
-                    timer.newTimeout(timeout -> {
-                        OpRequestSend peek = 
outstandingRequests.remove(op.requestId);
-                        if (peek != null && !peek.cb.isDone() && 
!peek.cb.isCompletedExceptionally()) {
-                            peek.cb.completeExceptionally(new 
TransactionBufferClientException
-                                    .RequestTimeoutException());
-                            onResponse(peek);
-                        }
-                    }, operationTimeoutInMills, TimeUnit.MILLISECONDS);
                     op.cmd.retain();
-                    clientCnx.ctx().writeAndFlush(op.cmd, 
clientCnx.ctx().voidPromise());
+                    clientCnx.ctx().writeAndFlush(op.cmd)
+                            .addListener(result -> {
+                                if (result.isSuccess()) {
+                                    outstandingRequests.put(op.requestId, op);
+                                } else {

Review Comment:
   `outstandingRequests.put(op.requestId, op)` Should be before writeAndFlush.



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