From f06627c40856f5b7778a872fd5c3bc6e2c9d1716 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 30 May 2018 16:09:07 +0200 Subject: [PATCH] Allow CompositeHealthIndicator to be created with a Map as before See gh-4965 --- .../HealthEndpointDocumentationTests.java | 3 +-- .../health/HealthEndpointWebExtensionTests.java | 3 +-- .../boot/actuate/health/CompositeHealthIndicator.java | 3 --- .../actuate/health/CompositeHealthIndicatorTests.java | 7 +++---- .../boot/actuate/health/HealthEndpointTests.java | 10 +++++----- 5 files changed, 10 insertions(+), 16 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java index 3b66e3d564..2e9b8655e8 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/documentation/HealthEndpointDocumentationTests.java @@ -27,7 +27,6 @@ import javax.sql.DataSource; import org.junit.Test; import org.springframework.boot.actuate.health.CompositeHealthIndicator; -import org.springframework.boot.actuate.health.DefaultHealthIndicatorRegistry; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthEndpoint; import org.springframework.boot.actuate.health.HealthIndicator; @@ -122,7 +121,7 @@ public class HealthEndpointDocumentationTests extends MockMvcEndpointDocumentati indicators.put("us2", () -> Health.up().withDetail("version", "1.0.4").build()); return new CompositeHealthIndicator(new OrderedHealthAggregator(), - new DefaultHealthIndicatorRegistry(indicators)); + indicators); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionTests.java index 625c3b7989..9c74545027 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/health/HealthEndpointWebExtensionTests.java @@ -25,7 +25,6 @@ import org.junit.Test; import org.springframework.boot.actuate.endpoint.SecurityContext; import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse; import org.springframework.boot.actuate.health.CompositeHealthIndicator; -import org.springframework.boot.actuate.health.DefaultHealthIndicatorRegistry; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.HealthEndpointWebExtension; import org.springframework.boot.actuate.health.HealthIndicator; @@ -436,7 +435,7 @@ public class HealthEndpointWebExtensionTests { nestedIndicators.put("one", simpleHealthIndicator()); nestedIndicators.put("two", () -> Health.up().build()); return new CompositeHealthIndicator(new OrderedHealthAggregator(), - new DefaultHealthIndicatorRegistry(nestedIndicators)); + nestedIndicators); } } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java index 804eb2be02..999b57128a 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeHealthIndicator.java @@ -49,10 +49,7 @@ public class CompositeHealthIndicator implements HealthIndicator { * @param healthAggregator the health aggregator * @param indicators a map of {@link HealthIndicator HealthIndicators} with the key * being used as an indicator name. - * @deprecated since 2.1.0 in favour of - * {@link #CompositeHealthIndicator(HealthAggregator, HealthIndicatorRegistry)} */ - @Deprecated public CompositeHealthIndicator(HealthAggregator healthAggregator, Map indicators) { this(healthAggregator, new DefaultHealthIndicatorRegistry(indicators)); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeHealthIndicatorTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeHealthIndicatorTests.java index 69778a0c54..4b24481ddc 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeHealthIndicatorTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/CompositeHealthIndicatorTests.java @@ -63,7 +63,7 @@ public class CompositeHealthIndicatorTests { indicators.put("one", this.one); indicators.put("two", this.two); CompositeHealthIndicator composite = new CompositeHealthIndicator( - this.healthAggregator, new DefaultHealthIndicatorRegistry(indicators)); + this.healthAggregator, indicators); Health result = composite.health(); assertThat(result.getDetails()).hasSize(2); assertThat(result.getDetails()).containsEntry("one", @@ -78,10 +78,9 @@ public class CompositeHealthIndicatorTests { indicators.put("db1", this.one); indicators.put("db2", this.two); CompositeHealthIndicator innerComposite = new CompositeHealthIndicator( - this.healthAggregator, new DefaultHealthIndicatorRegistry(indicators)); + this.healthAggregator, indicators); CompositeHealthIndicator composite = new CompositeHealthIndicator( - this.healthAggregator, new DefaultHealthIndicatorRegistry( - Collections.singletonMap("db", innerComposite))); + this.healthAggregator, Collections.singletonMap("db", innerComposite)); Health result = composite.health(); ObjectMapper mapper = new ObjectMapper(); assertThat(mapper.writeValueAsString(result)).isEqualTo( diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java index 2b5a56510b..788ce2b21f 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/health/HealthEndpointTests.java @@ -78,8 +78,8 @@ public class HealthEndpointTests { @Test public void statusForComponentInstanceIsExposed() { CompositeHealthIndicator compositeIndicator = new CompositeHealthIndicator( - new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry( - Collections.singletonMap("sub", () -> Health.down().build()))); + new OrderedHealthAggregator(), + Collections.singletonMap("sub", () -> Health.down().build())); HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( Collections.singletonMap("test", compositeIndicator))); Health health = endpoint.healthForComponentInstance("test", "sub"); @@ -91,8 +91,8 @@ public class HealthEndpointTests { @Test public void statusForUnknownComponentInstanceReturnNull() { CompositeHealthIndicator compositeIndicator = new CompositeHealthIndicator( - new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry( - Collections.singletonMap("sub", () -> Health.down().build()))); + new OrderedHealthAggregator(), + Collections.singletonMap("sub", () -> Health.down().build())); HealthEndpoint endpoint = new HealthEndpoint(createHealthIndicator( Collections.singletonMap("test", compositeIndicator))); Health health = endpoint.healthForComponentInstance("test", "does-not-exist"); @@ -110,7 +110,7 @@ public class HealthEndpointTests { private HealthIndicator createHealthIndicator( Map healthIndicators) { return new CompositeHealthIndicator(new OrderedHealthAggregator(), - new DefaultHealthIndicatorRegistry(healthIndicators)); + healthIndicators); } }