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.
This commit is contained in:
parent
672d713f99
commit
8853c7c352
|
|
@ -1 +0,0 @@
|
||||||
/target
|
|
||||||
|
|
@ -100,7 +100,7 @@ public class PropertySourcesPropertyValues implements PropertyValues {
|
||||||
// that's better than nothing...
|
// that's better than nothing...
|
||||||
for (String propertyName : exacts) {
|
for (String propertyName : exacts) {
|
||||||
Object value;
|
Object value;
|
||||||
value = source.getProperty(propertyName);
|
value = resolver.getProperty(propertyName);
|
||||||
if (value != null && !this.propertyValues.containsKey(propertyName)) {
|
if (value != null && !this.propertyValues.containsKey(propertyName)) {
|
||||||
this.propertyValues.put(propertyName, new PropertyValue(
|
this.propertyValues.put(propertyName, new PropertyValue(
|
||||||
propertyName, value));
|
propertyName, value));
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,23 @@ public class PropertySourcesPropertyValuesTests {
|
||||||
assertEquals("bar", propertyValues.getPropertyValue("name").getValue());
|
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
|
@Test
|
||||||
public void testOverriddenValue() {
|
public void testOverriddenValue() {
|
||||||
this.propertySources.addFirst(new MapPropertySource("new", Collections
|
this.propertySources.addFirst(new MapPropertySource("new", Collections
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue