aloyszhang commented on code in PR #9900:
URL: https://github.com/apache/inlong/pull/9900#discussion_r1544133918
##########
inlong-common/src/main/java/org/apache/inlong/common/monitor/CounterGroup.java:
##########
@@ -59,9 +59,7 @@ public synchronized void set(String name, Long value) {
}
public synchronized AtomicLong getCounter(String name) {
- if (!this.counters.containsKey(name)) {
- this.counters.put(name, new AtomicLong());
- }
+ this.counters.computeIfAbsent(name, k -> new AtomicLong());
Review Comment:
Suggestion:
```java
return this.counters.computeIfAbsent(name, k -> new AtomicLong());
```
##########
inlong-common/src/main/java/org/apache/inlong/common/monitor/CounterGroupExt.java:
##########
@@ -75,9 +75,7 @@ public synchronized void set(String name, Long value) {
}
public synchronized AtomicLong getCounter(String name) {
- if (!this.counters.containsKey(name)) {
- this.counters.put(name, new AtomicLong());
- }
+ this.counters.computeIfAbsent(name, k -> new AtomicLong());
Review Comment:
ditto here.
--
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]