From 1a0f21983f7ca7c943c3dc4aa6e7672380d53aaf Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Mon, 17 Jul 2017 15:25:31 -0700 Subject: [PATCH] Fix tests Fixes gh-3832 --- .../properties/bind/handler/NoUnboundElementsBindHandler.java | 2 +- .../ConfigurationPropertiesBindingPostProcessorTests.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/NoUnboundElementsBindHandler.java b/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/NoUnboundElementsBindHandler.java index b0f0ae5fd3..709608b4a5 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/NoUnboundElementsBindHandler.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/NoUnboundElementsBindHandler.java @@ -77,7 +77,7 @@ public class NoUnboundElementsBindHandler extends AbstractBindHandler { BindContext context) { Set unbound = new TreeSet<>(); for (ConfigurationPropertySource source : context.getSources()) { - if (this.filter.apply(source)) { + if (source instanceof IterableConfigurationPropertySource && this.filter.apply(source)) { collectUnbound(name, unbound, (IterableConfigurationPropertySource) source); } diff --git a/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorTests.java b/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorTests.java index 58c915b1b4..ef23539502 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessorTests.java @@ -48,6 +48,7 @@ import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.MapPropertySource; import org.springframework.core.env.MutablePropertySources; +import org.springframework.core.env.StandardEnvironment; import org.springframework.core.env.SystemEnvironmentPropertySource; import org.springframework.mock.env.MockEnvironment; import org.springframework.test.context.support.TestPropertySourceUtils; @@ -426,7 +427,7 @@ public class ConfigurationPropertiesBindingPostProcessorTests { MutablePropertySources propertySources = env.getPropertySources(); propertySources.addFirst(new MapPropertySource("test", Collections.singletonMap("com.example.foo", 5))); - propertySources.addLast(new SystemEnvironmentPropertySource("system", + propertySources.addLast(new SystemEnvironmentPropertySource(StandardEnvironment.SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, Collections.singletonMap("COM_EXAMPLE_OTHER", "10"))); this.context.register(TestConfiguration.class); this.context.refresh();