zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fang...@apache.org
Subject [zookeeper] branch master updated: ZOOKEEPER-3694: Use Map computeIfAbsent in AvgMinMaxCounterSet Class
Date Thu, 16 Jan 2020 20:46:17 GMT
This is an automated email from the ASF dual-hosted git repository.

fangmin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new f530ab9  ZOOKEEPER-3694: Use Map computeIfAbsent in AvgMinMaxCounterSet Class
f530ab9 is described below

commit f530ab91f1986027223bff72f01f965a24d6fd53
Author: David Mollitor <dmollitor@apache.org>
AuthorDate: Thu Jan 16 12:46:10 2020 -0800

    ZOOKEEPER-3694: Use Map computeIfAbsent in AvgMinMaxCounterSet Class
    
    Author: David Mollitor <dmollitor@apache.org>
    
    Reviewers: eolivelli@apache.org, maoling199210191@sina.com, fangmin@apache.org
    
    Closes #1218 from belugabehr/ZOOKEEPER-3694
---
 .../org/apache/zookeeper/server/metric/AvgMinMaxCounterSet.java   | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/metric/AvgMinMaxCounterSet.java
b/zookeeper-server/src/main/java/org/apache/zookeeper/server/metric/AvgMinMaxCounterSet.java
index 8d96111..8696950 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/metric/AvgMinMaxCounterSet.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/metric/AvgMinMaxCounterSet.java
@@ -39,13 +39,7 @@ public class AvgMinMaxCounterSet extends Metric implements SummarySet {
     }
 
     private AvgMinMaxCounter getCounterForKey(String key) {
-        AvgMinMaxCounter counter = counters.get(key);
-        if (counter == null) {
-            counters.putIfAbsent(key, new AvgMinMaxCounter(key + "_" + name));
-            counter = counters.get(key);
-        }
-
-        return counter;
+        return counters.computeIfAbsent(key, k-> new AvgMinMaxCounter(k + "_" + name));
     }
 
     public void addDataPoint(String key, long value) {


Mime
View raw message