diff --git a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java index 3ef9bf8e..5f9c35f1 100644 --- a/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java +++ b/spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/BootstrapApplicationListener.java @@ -152,8 +152,8 @@ public class BootstrapApplicationListener } ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); // Use names and ensure unique to protect against duplicates - List names = SpringFactoriesLoader - .loadFactoryNames(BootstrapConfiguration.class, classLoader); + List names = new ArrayList<>(SpringFactoriesLoader + .loadFactoryNames(BootstrapConfiguration.class, classLoader)); for (String name : StringUtils.commaDelimitedListToStringArray( environment.getProperty("spring.cloud.bootstrap.sources", ""))) { names.add(name); diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java index 39f0891f..1e52461b 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/context/refresh/ContextRefresherTests.java @@ -1,5 +1,7 @@ package org.springframework.cloud.context.refresh; +import static org.assertj.core.api.Assertions.assertThat; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -19,15 +21,13 @@ import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; -import static org.assertj.core.api.Assertions.assertThat; - public class ContextRefresherTests { private RefreshScope scope = Mockito.mock(RefreshScope.class); @Test public void orderNewPropertiesConsistentWithNewContext() { - try (ConfigurableApplicationContext context = SpringApplication.run(ContextRefresherTests.class, + try (ConfigurableApplicationContext context = SpringApplication.run(Empty.class, "--spring.main.webEnvironment=false", "--debug=false", "--spring.main.bannerMode=OFF")) { context.getEnvironment().setActiveProfiles("refresh"); @@ -50,10 +50,11 @@ public class ContextRefresherTests { public void bootstrapPropertySourceAlwaysFirst() { // Use spring.cloud.bootstrap.name to switch off the defaults (which would pick up // a bootstrapProperties immediately - try (ConfigurableApplicationContext context = SpringApplication.run(ContextRefresherTests.class, + try (ConfigurableApplicationContext context = SpringApplication.run(Empty.class, "--spring.main.webEnvironment=false", "--debug=false", "--spring.main.bannerMode=OFF", "--spring.cloud.bootstrap.name=refresh")) { List names = names(context.getEnvironment().getPropertySources()); + System.err.println("***** " + context.getEnvironment().getPropertySources()); assertThat(names).doesNotContain("bootstrapProperties"); ContextRefresher refresher = new ContextRefresher(context, scope); TestPropertyValues.of( @@ -73,6 +74,10 @@ public class ContextRefresherTests { return list; } + @Configuration + protected static class Empty { + } + @Configuration // This is added to bootstrap context as a source in bootstrap.properties protected static class PropertySourceConfiguration implements PropertySourceLocator { diff --git a/spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java b/spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java index 66b53a45..80b79276 100644 --- a/spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java +++ b/spring-cloud-context/src/test/java/org/springframework/cloud/endpoint/RefreshEndpointTests.java @@ -28,7 +28,6 @@ import java.util.List; import java.util.Map; import org.junit.After; -import org.junit.Ignore; import org.junit.Test; import org.springframework.boot.Banner.Mode; import org.springframework.boot.WebApplicationType; @@ -94,7 +93,6 @@ public class RefreshEndpointTests { } @Test - // @Ignore public void keysComputedWhenChangesInExternalProperties() throws Exception { this.context = new SpringApplicationBuilder(Empty.class) .web(WebApplicationType.NONE).bannerMode(Mode.OFF)