Ensure properties that are not enumerable can be resolved from placeholders

Before this change a property whose key was in a non-enumerable property source would
not resolve placeholders, leading to ${style} values in @ConfigurationProperties beans
even if the placeholders ere resolvable.
pull/1286/head
Dave Syer 10 years ago
parent 672d713f99
commit 8853c7c352

@ -100,7 +100,7 @@ public class PropertySourcesPropertyValues implements PropertyValues {
// that's better than nothing...
for (String propertyName : exacts) {
Object value;
value = source.getProperty(propertyName);
value = resolver.getProperty(propertyName);
if (value != null && !this.propertyValues.containsKey(propertyName)) {
this.propertyValues.put(propertyName, new PropertyValue(
propertyName, value));

@ -73,6 +73,23 @@ public class PropertySourcesPropertyValuesTests {
assertEquals("bar", propertyValues.getPropertyValue("name").getValue());
}
@Test
public void testNonEnumeratedPlaceholder() {
this.propertySources.addFirst(new PropertySource<String>("another", "baz") {
@Override
public Object getProperty(String name) {
if (name.equals(getSource())) {
return "${foo}";
}
return null;
}
});
PropertySourcesPropertyValues propertyValues = new PropertySourcesPropertyValues(
this.propertySources, null, Collections.singleton("baz"));
assertEquals("bar", propertyValues.getPropertyValue("baz").getValue());
}
@Test
public void testOverriddenValue() {
this.propertySources.addFirst(new MapPropertySource("new", Collections

Loading…
Cancel
Save