diff --git a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherFactory.java b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherFactory.java index 98c7813eb..e999b1a76 100644 --- a/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherFactory.java +++ b/hystrix-core/src/main/java/com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisherFactory.java @@ -97,22 +97,22 @@ public static void reset() { /* package */ HystrixMetricsPublisherFactory() {} - // String is CommandKey.name() (we can't use CommandKey directly as we can't guarantee it implements hashcode/equals correctly) private final ConcurrentHashMap commandPublishers = new ConcurrentHashMap(); /* package */ HystrixMetricsPublisherCommand getPublisherForCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandOwner, HystrixCommandMetrics metrics, HystrixCircuitBreaker circuitBreaker, HystrixCommandProperties properties) { // attempt to retrieve from cache first - HystrixMetricsPublisherCommand publisher = commandPublishers.get(commandKey.name()); + String cacheKey = commandOwner.name() + commandKey.name(); + HystrixMetricsPublisherCommand publisher = commandPublishers.get(cacheKey); if (publisher != null) { return publisher; } else { synchronized (this) { - HystrixMetricsPublisherCommand existingPublisher = commandPublishers.get(commandKey.name()); + HystrixMetricsPublisherCommand existingPublisher = commandPublishers.get(cacheKey); if (existingPublisher != null) { return existingPublisher; } else { HystrixMetricsPublisherCommand newPublisher = HystrixPlugins.getInstance().getMetricsPublisher().getMetricsPublisherForCommand(commandKey, commandOwner, metrics, circuitBreaker, properties); - commandPublishers.putIfAbsent(commandKey.name(), newPublisher); + commandPublishers.putIfAbsent(cacheKey, newPublisher); newPublisher.initialize(); return newPublisher; }