Skip to content

Commit fc43761

Browse files
committed
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
1 parent f1ecf53 commit fc43761

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

spring-boot/src/main/java/org/springframework/boot/bind/PropertySourcesPropertyValues.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ public PropertySourcesPropertyValues(PropertySources propertySources,
9898
private void processPropertySource(PropertySource<?> source,
9999
PropertySourcesPropertyResolver resolver,
100100
PropertyNamePatternsMatcher includes, Collection<String> exacts) {
101-
if (source instanceof EnumerablePropertySource) {
102-
processEnumerablePropertySource((EnumerablePropertySource<?>) source,
103-
resolver, includes, exacts);
104-
}
105-
else if (source instanceof CompositePropertySource) {
101+
if (source instanceof CompositePropertySource) {
106102
processCompositePropertySource((CompositePropertySource) source, resolver,
107103
includes, exacts);
108104
}
105+
else if (source instanceof EnumerablePropertySource) {
106+
processEnumerablePropertySource((EnumerablePropertySource<?>) source,
107+
resolver, includes);
108+
}
109109
else {
110110
// We can only do exact matches for non-enumerable property names, but
111111
// that's better than nothing...
@@ -114,8 +114,7 @@ else if (source instanceof CompositePropertySource) {
114114
}
115115

116116
private void processEnumerablePropertySource(EnumerablePropertySource<?> source,
117-
PropertySourcesPropertyResolver resolver,
118-
PropertyNamePatternsMatcher includes, Collection<String> exacts) {
117+
PropertySourcesPropertyResolver resolver, PropertyNamePatternsMatcher includes) {
119118
if (source.getPropertyNames().length > 0) {
120119
for (String propertyName : source.getPropertyNames()) {
121120
if (PropertySourcesPropertyValues.PATTERN_MATCHED_PROPERTY_SOURCES

0 commit comments

Comments
 (0)