poorbarcode commented on code in PR #16540:
URL: https://github.com/apache/pulsar/pull/16540#discussion_r941329929


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceTest.java:
##########
@@ -979,7 +981,32 @@ public void testLookupThrottlingForClientByClient() throws 
Exception {
         EventLoopGroup eventLoop = EventLoopUtil.newEventLoopGroup(20, false,
                 new DefaultThreadFactory("test-pool", 
Thread.currentThread().isDaemon()));
         long reqId = 0xdeadbeef;
-        try (ConnectionPool pool = new ConnectionPool(conf, eventLoop)) {
+
+        Semaphore clientCnxSemaphore = new Semaphore(1);
+        AtomicInteger count = new AtomicInteger(2);
+        try (ConnectionPool pool = new ConnectionPool(conf, eventLoop, () -> 
new ClientCnx(conf, eventLoop) {
+            @Override
+            protected void handleLookupResponse(CommandLookupTopicResponse 
lookupResult) {
+                try {
+                    clientCnxSemaphore.acquire();

Review Comment:
   > Because they are request concurrently, then one of the requests, e.g., 
request3, still have the chance that begin sending request after request1 and 
request2 completed
   
   No, Before we execute `countDownLacth.countDown`, the third request has 
already failed. see:
   
   
https://github.com/apache/pulsar/blob/be57e714c4b9de4e34f159285a44bd935b1d5367/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ClientCnx.java#L790
   
   I think you misunderstood me,Here's what I'm trying to say:
   
   ```
   // override the clientCnx
   static class CountDownLatchCnx extends ClientCnx{
       @Override
       void handleLookupResponse(){
           // countDownLatch.await();
       }
   }
   
   consumer1.lookup(...)
   consumer2.lookup(...)
   consumer3.lookup(...) // this request will be fail.
   
   countDownLatch.countDown();
   ```



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