mjsax commented on code in PR #20665:
URL: https://github.com/apache/kafka/pull/20665#discussion_r2415235787


##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/StreamTask.java:
##########
@@ -505,12 +497,12 @@ private Map<TopicPartition, OffsetAndMetadata> 
committableOffsetsAndMetadata() {
                 // input partitions
                 final Set<TopicPartition> partitionsNeedCommit = 
processorContext.processorMetadata().needsCommit() ?
                     inputPartitions() : consumedOffsets.keySet();
-                committableOffsets = new 
HashMap<>(partitionsNeedCommit.size());
 
-                for (final TopicPartition partition : partitionsNeedCommit) {
-                    committableOffsets.put(partition, 
findOffsetAndMetadata(partition));
-                }
-                break;
+                return partitionsNeedCommit.stream()
+                        .flatMap(partition -> findOffsetAndMetadata(partition)

Review Comment:
   Java streams API always confused me. Why do we use `flatMap` here? Don't we 
get a single entry in "committableOffsets" Map that we compute here? Or is it 
needed, because we might drop some partitions?



-- 
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]

Reply via email to