cadonna commented on code in PR #16562: URL: https://github.com/apache/kafka/pull/16562#discussion_r1687622157
########## streams/src/test/java/org/apache/kafka/streams/processor/internals/DefaultStateUpdaterTest.java: ########## @@ -325,14 +325,15 @@ private void shouldImmediatelyAddStatelessTasksToRestoredTasks(final StreamTask. public void shouldRestoreSingleActiveStatefulTask() throws Exception { final StreamTask task = statefulTask(TASK_0_0, mkSet(TOPIC_PARTITION_A_0, TOPIC_PARTITION_B_0)).inState(State.RESTORING).build(); + final AtomicBoolean allChangelogCompleted = new AtomicBoolean(false); when(changelogReader.completedChangelogs()) .thenReturn(Collections.emptySet()) .thenReturn(mkSet(TOPIC_PARTITION_A_0)) - .thenReturn(mkSet(TOPIC_PARTITION_A_0, TOPIC_PARTITION_B_0)); - when(changelogReader.allChangelogsCompleted()) - .thenReturn(false) - .thenReturn(false) - .thenReturn(true); + .thenAnswer(invocation -> { + allChangelogCompleted.set(true); + return mkSet(TOPIC_PARTITION_A_0, TOPIC_PARTITION_B_0); + }); + when(changelogReader.allChangelogsCompleted()).thenReturn(allChangelogCompleted.get()); Review Comment: The last `.thenReturn()` determines the return value for all following calls to `allChangelogCompleted()`. However, I realize now that it should probably be ``` when(changelogReader.allChangelogsCompleted()).thenAnswer(invocation -> allChangelogCompleted.get()); ``` Otherwise, I would always return `false`. I am a bit confused now, because the test ran successfully. I have to revisit this. -- 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