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


##########
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:
   That should be it. message consume is async.



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