lhotari commented on code in PR #23551:
URL: https://github.com/apache/pulsar/pull/23551#discussion_r1829967140


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TransactionBufferHandlerImpl.java:
##########
@@ -237,26 +240,25 @@ public void onResponse(OpRequestSend op) {
     }
 
     private void checkPendingRequests() {
-        while (true) {
-            int permits = REQUEST_CREDITS_UPDATER.get(this);
-            if (permits > 0 && pendingRequests.peek() != null) {
-                if (REQUEST_CREDITS_UPDATER.compareAndSet(this, permits, 
permits - 1)) {
-                    OpRequestSend polled = pendingRequests.poll();
-                    if (polled != null) {
-                        CompletableFuture<ClientCnx> clientCnx = 
getClientCnx(polled.topic);
-                        if (polled.cnx != clientCnx) {
-                            OpRequestSend invalid = polled;
-                            polled = OpRequestSend.create(invalid.requestId, 
invalid.topic, invalid.cmd, invalid.cb,
-                                    clientCnx);
-                            invalid.recycle();
-                        }
-                        endTxn(polled);
-                    } else {
-                        REQUEST_CREDITS_UPDATER.incrementAndGet(this);
+        int permits = REQUEST_CREDITS_UPDATER.get(this);
+        if (permits > 0 && pendingRequests.peek() != null) {
+            if (REQUEST_CREDITS_UPDATER.compareAndSet(this, permits, permits - 
1)) {
+                OpRequestSend polled = pendingRequests.poll();
+                if (polled != null) {
+                    CompletableFuture<ClientCnx> clientCnx = 
getClientCnx(polled.topic);
+                    if (polled.cnx != clientCnx) {
+                        OpRequestSend invalid = polled;
+                        polled = OpRequestSend.create(invalid.requestId, 
invalid.topic, invalid.cmd, invalid.cb,
+                                clientCnx);
+                        invalid.recycle();
                     }
+                    endTxn(polled);
+                } else {
+                    REQUEST_CREDITS_UPDATER.incrementAndGet(this);
+                    checkPendingRequests();
                 }
             } else {
-                break;
+                checkPendingRequests();

Review Comment:
   just wondering if deeply nested recursive calls could become a problem. is 
there a specific reason to replace the while loop with recursion?



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