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


##########
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:
   Oh, I get your point now @poorbarcode , thanks for your explantion. 
   
   I have thought using `CountDownLatch` here before,   But `CountDownLatch` 
has a problem that it can not reset it's count, which means we can not reuse it 
with multi cases in this test.  So I chosen using `Semaphore` here.



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