rreddy-22 commented on code in PR #14416:
URL: https://github.com/apache/kafka/pull/14416#discussion_r1378192398


##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/consumer/SubscribedTopicMetadata.java:
##########
@@ -68,12 +68,12 @@ public int numPartitions(Uuid topicId) {
      * @param topicId       Uuid corresponding to the partition's topic.
      * @param partition     Partition Id within the topic.
      * @return The set of racks corresponding to the replicas of the topics 
partition.
-     *         If the topic Id does not exist, an empty set is returned
+     *         If the topic Id does not exist or no partition rack information 
is available, an empty set is returned.
      */
     @Override
     public Set<String> racksForPartition(Uuid topicId, int partition) {
         TopicMetadata topic = this.topicMetadata.get(topicId);
-        return topic == null ? Collections.emptySet() : 
topic.partitionRacks().get(partition);
+        return topic == null ? Collections.emptySet() : 
topic.partitionRacks().getOrDefault(partition, Collections.emptySet());

Review Comment:
   good idea, I'll add for numPartitions as well, thanks!



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