RobertIndie commented on code in PR #15144:
URL: https://github.com/apache/pulsar/pull/15144#discussion_r849362196


##########
pulsar-broker/src/test/java/org/apache/pulsar/client/impl/ZeroQueueSizeTest.java:
##########
@@ -305,17 +306,23 @@ public void testFailedZeroQueueSizeBatchMessage() throws 
PulsarClientException {
             producer.send(message.getBytes());
         }
 
-        try {
-            consumer.receiveAsync().handle((ok, e) -> {
-                if (e == null) {
-                    // as zero receiverQueueSize doesn't support batch 
message, must receive exception at callback.
-                    Assert.fail();
-                }
-                return null;
-            });
-        } finally {
-            consumer.close();
-        }
+        AtomicReference<Throwable> exceptionRef = new AtomicReference<>();
+
+        consumer.receiveAsync().handle((ok, e) -> {
+            // as zero receiverQueueSize doesn't support batch message, must 
receive exception at callback.
+            exceptionRef.set(e);
+            return null;
+        });
+        Awaitility.await().untilAsserted(() -> 
assertNotNull(exceptionRef.get()));
+        Awaitility.await().untilAsserted(() -> 
assertEquals(exceptionRef.get().getClass(),
+                PulsarClientException.InvalidMessageException.class));
+        Awaitility.await().untilAsserted(() -> 
assertEquals(exceptionRef.get().getMessage(),

Review Comment:
   Sorry, I didn't express my point clearly. The lines 317 and 319 seem not 
need to await unitlAsserted. Once we get the `exceptionRef` on line 316, the 
subsequent assert should not have to wait.



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