You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "chia7712 (via GitHub)" <gi...@apache.org> on 2026/07/03 17:04:36 UTC

Re: [PR] KAFKA-20598: Prevent polling unassigned consumer during ConsumerTask shutdown [kafka]

chia7712 commented on code in PR #22328:
URL: https://github.com/apache/kafka/pull/22328#discussion_r3521136450


##########
storage/src/test/java/org/apache/kafka/server/log/remote/metadata/storage/ConsumerTaskTest.java:
##########
@@ -104,6 +112,20 @@ public void testCloseOnNoAssignment() {
         assertDoesNotThrow(() -> consumerTask.closeConsumer(), "CloseConsumer method threw exception");
     }
 
+    @Test
+    public void testCloseBeforeAssignmentDoesNotPollConsumer() {
+        final Consumer<byte[], byte[]> mockConsumer = mock(Consumer.class);
+        when(mockConsumer.poll(any(Duration.class)))

Review Comment:
   ```java
           when(mockConsumer.poll(any(Duration.class)))
               .thenThrow(new AssertionError("poll() should not be called when ConsumerTask is closed before any partition assignment"));
   ```
   this is unnecessary due to following verify, right?



-- 
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-unsubscribe@kafka.apache.org

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