You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/02/02 18:45:42 UTC

[GitHub] [kafka] abbccdda commented on a change in pull request #10017: KAFKA-12260: Avoid hitting NPE for partitionsFor

abbccdda commented on a change in pull request #10017:
URL: https://github.com/apache/kafka/pull/10017#discussion_r568845018



##########
File path: clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java
##########
@@ -1948,7 +1948,7 @@ public OffsetAndMetadata committed(TopicPartition partition, final Duration time
             Timer timer = time.timer(timeout);
             Map<String, List<PartitionInfo>> topicMetadata = fetcher.getTopicMetadata(
                     new MetadataRequest.Builder(Collections.singletonList(topic), metadata.allowAutoTopicCreation()), timer);
-            return topicMetadata.get(topic);
+            return topicMetadata.getOrDefault(topic, Collections.emptyList());

Review comment:
       I don't think you could have a topic with 0 partition.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org