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


##########
clients/src/test/java/org/apache/kafka/clients/consumer/KafkaConsumerTest.java:
##########
@@ -2965,7 +2970,28 @@ 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 (groupProtocol == GroupProtocol.CONSUMER) {
+            // 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
+            assertPollEventuallyThrows(consumer, InvalidTopicException.class,
+                    "Consumer was not able to update fetch positions on 
continuous calls with 0 timeout");
+        } else {
+            assertThrows(InvalidTopicException.class, () -> 
consumer.poll(Duration.ZERO));
+        }
+    }
+
+    private <T extends Throwable> void 
assertPollEventuallyThrows(KafkaConsumer<?, ?> consumer,

Review Comment:
   It can be static function, update later.



-- 
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: jira-unsubscr...@kafka.apache.org

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

Reply via email to