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


##########
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)
+                                .map(offsetAndMetadata -> Map.entry(partition, 
offsetAndMetadata))

Review Comment:
   If `findOffsetAndMetadata` returns an empty `Optional`, the partition will 
be dropped, and we does not end up in the computed "committableOffsets" `Map`, 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to