Copilot commented on code in PR #24256:
URL: https://github.com/apache/kafka/pull/24256#discussion_r4641700480
##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StoreChangelogReader.java:
##########
@@ -866,11 +870,7 @@ private Set<Task> getTasksFromPartitions(final Map<TaskId,
Task> tasks,
}
private void clearTaskTimeout(final Set<Task> tasks) {
- tasks.forEach(t -> {
- if (t != null) {
- t.clearTaskTimeout();
- }
- });
+ tasks.forEach(Task::clearTaskTimeout);
}
Review Comment:
This change removes the previous null-guard when clearing task timeouts. The
old implementation strongly suggests `tasks` may contain `null` entries (e.g.,
if built from a map lookup where a task can be missing). As-is,
`tasks.forEach(Task::clearTaskTimeout)` will throw a NullPointerException if
any element is null. Either ensure the set cannot contain nulls by construction
(preferred, e.g., in the method that builds this Set), or restore a
null-filter/guard before invoking `clearTaskTimeout()`.
##########
streams/src/test/java/org/apache/kafka/streams/processor/internals/StoreChangelogReaderTest.java:
##########
@@ -1260,6 +1261,70 @@ public void
logicalChangelogEndOffsetsShouldReturnNullWhenBothSourcesUnknown() {
assertNull(changelogReader.logicalChangelogEndOffsets().get(tp));
}
+ @Test
+ public void shouldNotLookUpLimitOffsetsForChangelogsOfPausedStandbyTasks()
{
+ setupStandbyStateManager();
+ setupStoreMetadata();
+ setupStore();
+ final TaskId taskId = new TaskId(0, 0);
+ when(standbyStateManager.taskId()).thenReturn(taskId);
+ when(standbyStateManager.changelogAsSource(tp)).thenReturn(true);
+ when(storeMetadata.offset()).thenReturn(3L);
+
+ final AtomicBoolean failLookups = new AtomicBoolean(false);
+ final AtomicInteger lookups = new AtomicInteger();
+ final MockAdminClient adminClient = new MockAdminClient() {
+ @Override
+ public synchronized ListConsumerGroupOffsetsResult
listConsumerGroupOffsets(final Map<String, ListConsumerGroupOffsetsSpec>
groupSpecs, final ListConsumerGroupOffsetsOptions options) {
+ lookups.incrementAndGet();
Review Comment:
The test override assumes `groupSpecs` is non-empty and calls
`iterator().next()`. If the production code ever calls
`listConsumerGroupOffsets` with an empty map (now or in future refactors), this
will throw `NoSuchElementException` and make the test failure misleading.
Consider asserting `!groupSpecs.isEmpty()` with a clear message, or handling
the empty case by delegating to `super.listConsumerGroupOffsets(groupSpecs,
options)`.
--
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]