diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthIndicator.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthIndicator.java index f928d5b8..388b9c02 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthIndicator.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/health/DiscoveryCompositeHealthIndicator.java @@ -17,7 +17,9 @@ package org.springframework.cloud.client.discovery.health; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.actuate.health.CompositeHealthIndicator; @@ -39,18 +41,27 @@ public class DiscoveryCompositeHealthIndicator extends CompositeHealthIndicator @Autowired public DiscoveryCompositeHealthIndicator(HealthAggregator healthAggregator, List indicators) { - super(healthAggregator); - for (DiscoveryHealthIndicator indicator : indicators) { - Holder holder = new Holder(indicator); - addHealthIndicator(indicator.getName(), holder); - this.healthIndicators.add(holder); - } + super(healthAggregator, createMap(indicators)); + getRegistry().getAll().values().stream() + .filter(healthIndicator -> healthIndicator instanceof Holder) + .forEach(healthIndicator -> this.healthIndicators + .add((Holder) healthIndicator)); } public ArrayList getHealthIndicators() { return this.healthIndicators; } + public static Map createMap( + List indicators) { + Map map = new HashMap<>(); + for (DiscoveryHealthIndicator indicator : indicators) { + Holder holder = new Holder(indicator); + map.put(indicator.getName(), holder); + } + return map; + } + /** * Holder for the Health Indicator. */ diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java index 02854a78..79e8d0ae 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/configuration/SpringBootVersionVerifier.java @@ -39,6 +39,7 @@ class SpringBootVersionVerifier implements CompatibilityVerifier { this.put("1.5", is1_5()); this.put("2.0", is2_0()); this.put("2.1", is2_1()); + this.put("2.2", is2_2()); } }; @@ -137,6 +138,30 @@ class SpringBootVersionVerifier implements CompatibilityVerifier { }; } + CompatibilityPredicate is2_2() { + return new CompatibilityPredicate() { + + @Override + public String toString() { + return "Predicate for Boot 2.2"; + } + + @Override + public boolean isCompatible() { + try { + // since 2.1 + Class.forName( + "org.springframework.boot.autoconfigure.flyway.FlywayMigrationScriptMissingException"); + return true; + } + catch (ClassNotFoundException e) { + return false; + } + + } + }; + } + private String errorDescription() { String versionFromManifest = getVersionFromManifest(); if (StringUtils.hasText(versionFromManifest)) { diff --git a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java index dec86310..0a288d5e 100644 --- a/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java +++ b/spring-cloud-commons/src/test/java/org/springframework/cloud/configuration/SpringBootDependencyTests.java @@ -144,7 +144,7 @@ public class SpringBootDependencyTests { @Test public void should_match_against_current_manifest() { - List acceptedVersions = Collections.singletonList("2.1"); + List acceptedVersions = Collections.singletonList("2.2"); SpringBootVersionVerifier versionVerifier = new SpringBootVersionVerifier( acceptedVersions); versionVerifier.ACCEPTED_VERSIONS.clear(); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java index 685fef83..4ed8f071 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/config/BootstrapListenerHierarchyIntegrationTests.java @@ -28,7 +28,7 @@ import static org.springframework.boot.WebApplicationType.NONE; /** * Integration tests for Bootstrap Listener's functionality of adding a bootstrap context - * as the root Application Context + * as the root Application Context. * * @author Biju Kunjummen */