Skip to content

Commit

Permalink
Move HealthCountsStream subscribe outside synchronized block
Browse files Browse the repository at this point in the history
  • Loading branch information
mattrjacobs committed Apr 7, 2017
1 parent 562d01f commit 0fc69b8
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,21 @@ public static HealthCountsStream getInstance(HystrixCommandKey commandKey, int n
if (initialStream != null) {
return initialStream;
} else {
final HealthCountsStream healthStream;
synchronized (HealthCountsStream.class) {
HealthCountsStream existingStream = streams.get(commandKey.name());
if (existingStream == null) {
HealthCountsStream newStream = new HealthCountsStream(commandKey, numBuckets, bucketSizeInMs,
HystrixCommandMetrics.appendEventToBucket);
newStream.startCachingStreamValuesIfUnstarted();

streams.putIfAbsent(commandKey.name(), newStream);
return newStream;
healthStream = newStream;
} else {
return existingStream;
healthStream = existingStream;
}
}
healthStream.startCachingStreamValuesIfUnstarted();
return healthStream;
}
}

Expand Down

0 comments on commit 0fc69b8

Please sign in to comment.