hachikuji commented on a change in pull request #9802:
URL: https://github.com/apache/kafka/pull/9802#discussion_r551641235



##########
File path: core/src/main/scala/kafka/server/MetadataCache.scala
##########
@@ -266,8 +266,16 @@ class MetadataCache(brokerId: Int) extends Logging {
 
   def getClusterMetadata(clusterId: String, listenerName: ListenerName): 
Cluster = {
     val snapshot = metadataSnapshot
-    val nodes = snapshot.aliveNodes.map { case (id, nodes) => (id, 
nodes.get(listenerName).orNull) }
-    def node(id: Integer): Node = nodes.get(id.toLong).orNull
+    val nodes = snapshot.aliveNodes.flatMap { case (id, nodesByListener) =>
+      nodesByListener.get(listenerName).map { node =>
+        id -> node
+      }
+    }
+
+    def node(id: Integer): Node = {
+      nodes.getOrElse(id.toLong, new Node(id, "", -1))

Review comment:
       That's not a bad idea. I think `Node` is public, though we haven't 
always been strict about requiring KIPs for new methods. A couple options are 
to add a new constructor or a static factory. We could also add a utility 
somewhere, but that feels a little clumsy. Thoughts?




----------------------------------------------------------------
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:
[email protected]


Reply via email to