lianetm commented on code in PR #16638:
URL: https://github.com/apache/kafka/pull/16638#discussion_r1686692620


##########
clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:
##########
@@ -2965,7 +2976,21 @@ public void testSubscriptionOnInvalidTopic(GroupProtocol 
groupProtocol) {
         KafkaConsumer<String, String> consumer = newConsumer(groupProtocol, 
time, client, subscription, metadata, assignor, true, groupInstanceId);
         consumer.subscribe(singleton(invalidTopicName), 
getConsumerRebalanceListener(consumer));
 
-        assertThrows(InvalidTopicException.class, () -> 
consumer.poll(Duration.ZERO));
+        if (isAyncConsumer(groupProtocol)) {
+            // New consumer poll(ZERO) needs to wait for the event added by a 
call to poll, to be processed
+            // by the background thread, so it can realize there is invalid 
topics and then
+            // throw the InvalidTopicException
+            TestUtils.waitForCondition(() -> {

Review Comment:
   Agreed, what about a kind of `assertPollEventuallyThrows(expectedException, 
errorMsg)` (or better named). We would use it for 
`NoOffsetForPartitionException`, `InvalidTopicException` and 
`AuthenticationException`



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