jolshan commented on a change in pull request #9626: URL: https://github.com/apache/kafka/pull/9626#discussion_r543485900
########## File path: core/src/main/scala/kafka/controller/KafkaController.scala ########## @@ -1378,12 +1378,26 @@ class KafkaController(val config: KafkaConfig, val offlineReplicas = new ArrayBuffer[TopicPartition]() val onlineReplicas = new ArrayBuffer[TopicPartition]() - leaderAndIsrResponse.partitions.forEach { partition => - val tp = new TopicPartition(partition.topicName, partition.partitionIndex) - if (partition.errorCode == Errors.KAFKA_STORAGE_ERROR.code) - offlineReplicas += tp - else if (partition.errorCode == Errors.NONE.code) - onlineReplicas += tp + if (leaderAndIsrResponse.topics().isEmpty) { + leaderAndIsrResponse.partitions.forEach { partition => + val topicName = partition.topicName + val tp = new TopicPartition(topicName, partition.partitionIndex) + if (partition.errorCode == Errors.KAFKA_STORAGE_ERROR.code) + offlineReplicas += tp + else if (partition.errorCode == Errors.NONE.code) + onlineReplicas += tp + } + } + + leaderAndIsrResponse.topics.forEach { topic => + val topicName = controllerContext.topicNames.get(topic.topicId).get + topic.partitionErrors().forEach { partition => + val tp = new TopicPartition(topicName, partition.partitionIndex) + if (partition.errorCode == Errors.KAFKA_STORAGE_ERROR.code) + offlineReplicas += tp + else if (partition.errorCode == Errors.NONE.code) + onlineReplicas += tp Review comment: I ended up moving some of this to the response class so the duplicate logic is removed. I just haven't pushed yet ---------------------------------------------------------------- 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: us...@infra.apache.org