From fc4376145cf740fe0fcbeaee5f369348de788331 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 16 Mar 2015 16:56:10 +0000 Subject: [PATCH] Process CompositePropertySources before EnumerablePropertySources PropertySourcePropertyValues tries to process a PropertySource first as an EnumerablePropertySource and then as a CompositePropertySource. In Spring 4.1.2 CompositePropertySource was updated to extend EnumerablePropertySource. This change meant that a CompositePropertySource would always be processed as an EnumerablePropertySource. This commit updates PropertySourcePropertyValues to process a PropertySource as a CompositePropertySource first and to then try it is an EnumerablePropertySource. Fixes gh-2608 --- .../boot/bind/PropertySourcesPropertyValues.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java index 57ce7606b2..9cd21f3c3b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java @@ -98,14 +98,14 @@ public class PropertySourcesPropertyValues implements PropertyValues { private void processPropertySource(PropertySource source, PropertySourcesPropertyResolver resolver, PropertyNamePatternsMatcher includes, Collection exacts) { - if (source instanceof EnumerablePropertySource) { - processEnumerablePropertySource((EnumerablePropertySource) source, - resolver, includes, exacts); - } - else if (source instanceof CompositePropertySource) { + if (source instanceof CompositePropertySource) { processCompositePropertySource((CompositePropertySource) source, resolver, includes, exacts); } + else if (source instanceof EnumerablePropertySource) { + processEnumerablePropertySource((EnumerablePropertySource) source, + resolver, includes); + } else { // We can only do exact matches for non-enumerable property names, but // that's better than nothing... @@ -114,8 +114,7 @@ public class PropertySourcesPropertyValues implements PropertyValues { } private void processEnumerablePropertySource(EnumerablePropertySource source, - PropertySourcesPropertyResolver resolver, - PropertyNamePatternsMatcher includes, Collection exacts) { + PropertySourcesPropertyResolver resolver, PropertyNamePatternsMatcher includes) { if (source.getPropertyNames().length > 0) { for (String propertyName : source.getPropertyNames()) { if (PropertySourcesPropertyValues.PATTERN_MATCHED_PROPERTY_SOURCES