zzbennett commented on code in PR #20061:
URL: https://github.com/apache/kafka/pull/20061#discussion_r2178759148


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java:
##########
@@ -8120,56 +8119,58 @@ public Map.Entry<AlterShareGroupOffsetsResponseData, 
InitializeShareGroupStatePa
         Map<Uuid, Map<Integer, Long>> offsetByTopicPartitions = new 
HashMap<>();
 
         alterShareGroupOffsetsRequest.topics().forEach(topic -> {
-            TopicImage topicImage = 
metadataImage.topics().getTopic(topic.topicName());
-            if (topicImage != null) {
-                Uuid topicId = topicImage.id();
-                Set<Integer> existingPartitions = new 
HashSet<>(topicImage.partitions().keySet());
-                
List<AlterShareGroupOffsetsResponseData.AlterShareGroupOffsetsResponsePartition>
 partitions = new ArrayList<>();
-                topic.partitions().forEach(partition -> {
-                    if 
(existingPartitions.contains(partition.partitionIndex())) {
-                        partitions.add(
-                            new 
AlterShareGroupOffsetsResponseData.AlterShareGroupOffsetsResponsePartition()
-                                .setPartitionIndex(partition.partitionIndex())
-                                .setErrorCode(Errors.NONE.code()));
-                        offsetByTopicPartitions.computeIfAbsent(topicId, k -> 
new HashMap<>()).put(partition.partitionIndex(), partition.startOffset());
-                    } else {
-                        partitions.add(
-                            new 
AlterShareGroupOffsetsResponseData.AlterShareGroupOffsetsResponsePartition()
-                                .setPartitionIndex(partition.partitionIndex())
-                                
.setErrorCode(Errors.UNKNOWN_TOPIC_OR_PARTITION.code())
-                                
.setErrorMessage(Errors.UNKNOWN_TOPIC_OR_PARTITION.message()));
-                    }
-                });
-
-                initializingTopics.put(topicId, new InitMapValue(
-                    topic.topicName(),
-                    topic.partitions().stream()
-                        
.map(AlterShareGroupOffsetsRequestData.AlterShareGroupOffsetsRequestPartition::partitionIndex)
-                        .filter(existingPartitions::contains)
-                        .collect(Collectors.toSet()),
-                    currentTimeMs
-                ));
+            metadataImage.topicMetadata(topic.topicName()).ifPresentOrElse(

Review Comment:
   By current structure, you mean the if/else block instead of the 
`ifPresenetOrElse`? I'm fine with either one. I agree the `ifPresentOrElse` is 
kind of hard to read when it's a big block of logic. It's probably better for 
one or two line pieces of logic



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

Reply via email to