You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/04/13 10:17:50 UTC

[GitHub] [pulsar] horizonzy commented on a diff in pull request #15144: [fix] [client-consumer] NotifyPendingReceivedCallback when zeroConsumerImpl received batch message firstly , then close consumer.

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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org