cmccabe commented on a change in pull request #10887:
URL: https://github.com/apache/kafka/pull/10887#discussion_r660928423



##########
File path: core/src/main/scala/kafka/server/ReplicaManager.scala
##########
@@ -1721,8 +1720,10 @@ class ReplicaManager(val config: KafkaConfig,
       } else {
         // we do not need to check if the leader exists again since this has 
been done at the beginning of this process
         val partitionsToMakeFollowerWithLeaderAndOffset = 
partitionsToMakeFollower.map { partition =>
-          val leader = metadataCache.getAliveBrokers.find(_.id == 
partition.leaderReplicaIdOpt.get).get
-            .brokerEndPoint(config.interBrokerListenerName)
+          val leaderNode = metadataCache.getAliveBrokerNode(
+            partition.leaderReplicaIdOpt.getOrElse(-1), 
config.interBrokerListenerName.value()).

Review comment:
       Hmm... `getAliveBrokerNode` returns `None` or `Some`, never `noNode`. 
Anyway, I don't feel strongly about this, so I just used the version you 
suggested. I suppose it's one less place where we use -1 as a sentinel value 
(although honestly, there are enough of these places that -1 will never be a 
valid node value in Kafka, I think.)




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