From 5e3b5ae14fed1cef6bc00a6bf62c8feffc2e1ffd Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 11 Oct 2018 17:25:54 +0100 Subject: [PATCH] Polish See gh-14780 and gh-14467 --- .../metrics/MeterRegistryPostProcessor.java | 23 +++++++++++-------- .../metrics/MetricsAutoConfiguration.java | 8 +++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryPostProcessor.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryPostProcessor.java index 6a2985b672..1c96c9c298 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryPostProcessor.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryPostProcessor.java @@ -16,8 +16,8 @@ package org.springframework.boot.actuate.autoconfigure.metrics; -import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import io.micrometer.core.instrument.MeterRegistry; import io.micrometer.core.instrument.binder.MeterBinder; @@ -37,19 +37,19 @@ import org.springframework.beans.factory.config.BeanPostProcessor; */ class MeterRegistryPostProcessor implements BeanPostProcessor { - private final ObjectProvider> meterBinders; + private final ObjectProvider meterBinders; - private final ObjectProvider> meterFilters; + private final ObjectProvider meterFilters; - private final ObjectProvider>> meterRegistryCustomizers; + private final ObjectProvider> meterRegistryCustomizers; private final ObjectProvider metricsProperties; private volatile MeterRegistryConfigurer configurer; - MeterRegistryPostProcessor(ObjectProvider> meterBinders, - ObjectProvider> meterFilters, - ObjectProvider>> meterRegistryCustomizers, + MeterRegistryPostProcessor(ObjectProvider meterBinders, + ObjectProvider meterFilters, + ObjectProvider> meterRegistryCustomizers, ObjectProvider metricsProperties) { this.meterBinders = meterBinders; this.meterFilters = meterFilters; @@ -69,12 +69,15 @@ class MeterRegistryPostProcessor implements BeanPostProcessor { private MeterRegistryConfigurer getConfigurer() { if (this.configurer == null) { this.configurer = new MeterRegistryConfigurer( - this.meterBinders.getIfAvailable(Collections::emptyList), - this.meterFilters.getIfAvailable(Collections::emptyList), - this.meterRegistryCustomizers.getIfAvailable(Collections::emptyList), + asOrderedList(this.meterBinders), asOrderedList(this.meterFilters), + asOrderedList(this.meterRegistryCustomizers), this.metricsProperties.getObject().isUseGlobalRegistry()); } return this.configurer; } + private List asOrderedList(ObjectProvider provider) { + return provider.orderedStream().collect(Collectors.toList()); + } + } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.java index 4d2d0d243c..7a2d49c816 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MetricsAutoConfiguration.java @@ -16,8 +16,6 @@ package org.springframework.boot.actuate.autoconfigure.metrics; -import java.util.List; - import io.micrometer.core.annotation.Timed; import io.micrometer.core.instrument.Clock; import io.micrometer.core.instrument.binder.MeterBinder; @@ -54,9 +52,9 @@ public class MetricsAutoConfiguration { @Bean public static MeterRegistryPostProcessor meterRegistryPostProcessor( - ObjectProvider> meterBinders, - ObjectProvider> meterFilters, - ObjectProvider>> meterRegistryCustomizers, + ObjectProvider meterBinders, + ObjectProvider meterFilters, + ObjectProvider> meterRegistryCustomizers, ObjectProvider metricsProperties) { return new MeterRegistryPostProcessor(meterBinders, meterFilters, meterRegistryCustomizers, metricsProperties);