AnonHxy commented on code in PR #15062:
URL: https://github.com/apache/pulsar/pull/15062#discussion_r844856906


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/NamespaceStatsAggregator.java:
##########
@@ -250,15 +250,18 @@ private static void getTopicStats(Topic topic, TopicStats 
stats, boolean include
         }
 
         topic.getReplicators().forEach((cluster, replicator) -> {
-            AggregatedReplicationStats aggReplStats = 
stats.replicationStats.computeIfAbsent(cluster,
-                    k -> new AggregatedReplicationStats());
-
             ReplicatorStatsImpl replStats = replicator.getStats();
+            AggregatedReplicationStats aggReplStats = 
stats.replicationStats.get(replicator.getRemoteCluster());
+            if (aggReplStats == null) {
+                aggReplStats =
+                        
stats.replicationStats.put(replicator.getRemoteCluster(), new 
AggregatedReplicationStats());

Review Comment:
   `HashMap#put` return the previous value associated with key.  Hence the 
return value is null



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

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to