diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/InMemoryMetricRepository.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/InMemoryMetricRepository.java index c1ce8697a6..35a64e4476 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/InMemoryMetricRepository.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/repository/InMemoryMetricRepository.java @@ -20,6 +20,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.HashSet; +import java.util.concurrent.ConcurrentNavigableMap; import org.springframework.boot.actuate.metrics.Metric; import org.springframework.boot.actuate.metrics.reader.PrefixMetricReader; @@ -40,6 +41,10 @@ public class InMemoryMetricRepository implements MetricRepository, MultiMetricRe private final Collection groups = new HashSet(); + public void setValues(ConcurrentNavigableMap> values) { + this.metrics.setValues(values); + } + @Override public void increment(Delta delta) { final String metricName = delta.getName(); diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/util/SimpleInMemoryRepository.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/util/SimpleInMemoryRepository.java index 87ba26382a..e8195b39f5 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/util/SimpleInMemoryRepository.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/util/SimpleInMemoryRepository.java @@ -18,11 +18,12 @@ package org.springframework.boot.actuate.metrics.util; import java.util.ArrayList; import java.util.NavigableMap; -import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentNavigableMap; import java.util.concurrent.ConcurrentSkipListMap; +import org.springframework.util.ConcurrentReferenceHashMap; + /** * Repository utility that stores stuff in memory with period-separated String keys. * @@ -30,9 +31,9 @@ import java.util.concurrent.ConcurrentSkipListMap; */ public class SimpleInMemoryRepository { - private final ConcurrentNavigableMap values = new ConcurrentSkipListMap(); + private ConcurrentNavigableMap values = new ConcurrentSkipListMap(); - private final ConcurrentMap locks = new ConcurrentHashMap(); + private final ConcurrentMap locks = new ConcurrentReferenceHashMap(); public static interface Callback { T modify(T current); @@ -96,6 +97,10 @@ public class SimpleInMemoryRepository { .values()); } + public void setValues(ConcurrentNavigableMap values) { + this.values = values; + } + protected NavigableMap getValues() { return this.values; }