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



##########
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:
       >  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?
   
   You are right.
   
   For another, is this a kind of behavior change to ```ClientQuotaCallback``` 
(if custom ```ClientQuotaCallback``` does depend on the ```null``` value)? If 
so, how we keep the compatibility or should we offer a helper method to enable 
```ClientQuotaCallback``` to validate the "new Node(id, "", -1)"?




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