diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/BufferCounterService.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/BufferCounterService.java index c68ca3d97af..0717b3df2b4 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/BufferCounterService.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/BufferCounterService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,8 +58,9 @@ public class BufferCounterService implements CounterService { } private String wrap(String metricName) { - if (this.names.containsKey(metricName)) { - return this.names.get(metricName); + String cached = this.names.get(metricName); + if (cached != null) { + return cached; } if (metricName.startsWith("counter") || metricName.startsWith("meter")) { return metricName; diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/dropwizard/DropwizardMetricServices.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/dropwizard/DropwizardMetricServices.java index b011dfa5b8a..7e4f6c92cc3 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/dropwizard/DropwizardMetricServices.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/dropwizard/DropwizardMetricServices.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -128,8 +128,9 @@ public class DropwizardMetricServices implements CounterService, GaugeService { } private String wrapName(String metricName, String prefix) { - if (this.names.containsKey(metricName)) { - return this.names.get(metricName); + String cached = this.names.get(metricName); + if (cached != null) { + return cached; } if (metricName.startsWith(prefix)) { return metricName; diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java index bd41b647d00..20b8183fac2 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/DefaultCounterService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,8 +55,9 @@ public class DefaultCounterService implements CounterService { } private String wrap(String metricName) { - if (this.names.containsKey(metricName)) { - return this.names.get(metricName); + String cached = this.names.get(metricName); + if (cached != null) { + return cached; } if (metricName.startsWith("counter.") || metricName.startsWith("meter.")) { return metricName;