FrankYang0529 commented on code in PR #16673:
URL: https://github.com/apache/kafka/pull/16673#discussion_r1722661831
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessorTest.java:
##########
@@ -145,6 +148,39 @@ public void testResetPositionsProcess() {
verify(applicationEventProcessor).process(any(ResetPositionsEvent.class));
}
+ @ParameterizedTest
+ @ValueSource(booleans = {true, false})
+ public void testAssignmentChangeEvent(boolean withGroupId) {
+ final long currentTimeMs = 12345;
+ AssignmentChangeEvent event = new AssignmentChangeEvent(currentTimeMs,
12345, Collections.emptyList());
+
+ setupProcessor(withGroupId);
+ doReturn(true).when(subscriptionState).assignFromUser(any());
+ processor.process(event);
+ if (withGroupId) {
+ verify(commitRequestManager).updateAutoCommitTimer(currentTimeMs);
+ verify(commitRequestManager).maybeAutoCommitAsync();
+ } else {
+ verify(commitRequestManager,
never()).updateAutoCommitTimer(currentTimeMs);
+ verify(commitRequestManager, never()).maybeAutoCommitAsync();
+ }
+ verify(metadata).requestUpdateForNewTopics();
+ assertDoesNotThrow(() -> event.future().get());
+
+ }
+
+ @Test
+ public void testAssignmentChangeEventWithException() {
+ AssignmentChangeEvent event = new AssignmentChangeEvent(12345, 12345,
Collections.emptyList());
+
+ setupProcessor(false);
+ doThrow(new
IllegalStateException()).when(subscriptionState).assignFromUser(any());
+ processor.process(event);
+
+ ExecutionException e = assertThrows(ExecutionException.class, () ->
event.future().get());
+ assertInstanceOf(IllegalStateException.class, e.getCause());
Review Comment:
This is in `SubscriptionState`.
https://github.com/apache/kafka/blob/42715654095d019effc478ab343c0132e02aa70f/clients/src/main/java/org/apache/kafka/clients/consumer/internals/SubscriptionState.java#L230-L231
In `KafkaConsumer#assign` java doc, we also mention this exception.
https://github.com/apache/kafka/blob/42715654095d019effc478ab343c0132e02aa70f/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java#L783-L784
--
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]