Skip to content

Commit 41c15f2

Browse files
committed
Polish concurrent gaugeLocks map access
See gh-1995
1 parent b519eda commit 41c15f2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/CodahaleMetricWriter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ else if (name.startsWith("timer")) {
103103
private Object getGuageLock(String name) {
104104
Object lock = this.gaugeLocks.get(name);
105105
if (lock == null) {
106-
this.gaugeLocks.putIfAbsent(name, new Object());
107-
lock = this.gaugeLocks.get(name);
106+
Object newLock = new Object();
107+
lock = this.gaugeLocks.putIfAbsent(name, newLock);
108+
lock = (lock == null ? newLock : lock);
108109
}
109110
return lock;
110111
}

0 commit comments

Comments
 (0)