From 2aaf556a1c56a2b830905f206751d804f060074e Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 27 Apr 2015 09:33:04 +0100 Subject: [PATCH] Ensure the default MetricWriter in Java 7 is not used in exporter --- .../MetricRepositoryAutoConfiguration.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricRepositoryAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricRepositoryAutoConfiguration.java index 0978c0c309..212e11cddb 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricRepositoryAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricRepositoryAutoConfiguration.java @@ -16,9 +16,11 @@ package org.springframework.boot.actuate.autoconfigure; +import java.util.ArrayList; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.actuate.metrics.CounterService; import org.springframework.boot.actuate.metrics.GaugeService; import org.springframework.boot.actuate.metrics.buffer.BufferCounterService; @@ -170,11 +172,20 @@ public class MetricRepositoryAutoConfiguration { @Autowired(required = false) private List writers; + @Autowired(required = false) + @Qualifier("actuatorMetricRepository") + private MetricWriter actuatorMetricRepository; + @Bean @ConditionalOnMissingBean @ConditionalOnBean(MetricWriter.class) public MetricCopyExporter messageChannelMetricExporter(MetricReader reader) { - return new MetricCopyExporter(reader, new CompositeMetricWriter(this.writers)) { + List writers = new ArrayList(this.writers); + if (this.actuatorMetricRepository != null + && writers.contains(this.actuatorMetricRepository)) { + writers.remove(this.actuatorMetricRepository); + } + return new MetricCopyExporter(reader, new CompositeMetricWriter(writers)) { @Scheduled(fixedDelayString = "${spring.metrics.export.delayMillis:5000}") @Override public void export() {