Polish concurrent gaugeLocks map access

See gh-1995
This commit is contained in:
Phillip Webb 2014-12-01 14:29:22 -08:00
parent b519eda441
commit 41c15f205f
1 changed files with 3 additions and 2 deletions

View File

@ -103,8 +103,9 @@ public class CodahaleMetricWriter implements MetricWriter {
private Object getGuageLock(String name) {
Object lock = this.gaugeLocks.get(name);
if (lock == null) {
this.gaugeLocks.putIfAbsent(name, new Object());
lock = this.gaugeLocks.get(name);
Object newLock = new Object();
lock = this.gaugeLocks.putIfAbsent(name, newLock);
lock = (lock == null ? newLock : lock);
}
return lock;
}