Merge branch '1.2.x' (types preserved in property values)
This commit is contained in:
commit
897834d37f
|
|
@ -121,12 +121,15 @@ public class PropertySourcesPropertyValues implements PropertyValues {
|
||||||
.contains(source.getName()) && !includes.matches(propertyName)) {
|
.contains(source.getName()) && !includes.matches(propertyName)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object value = source.getProperty(propertyName);
|
Object value = null;
|
||||||
try {
|
try {
|
||||||
value = resolver.getProperty(propertyName);
|
value = resolver.getProperty(propertyName, Object.class);
|
||||||
}
|
}
|
||||||
catch (RuntimeException ex) {
|
catch (RuntimeException ex) {
|
||||||
// Probably could not resolve placeholders, ignore it here
|
// Probably could not resolve placeholders, ignore it here
|
||||||
|
if (value == null) {
|
||||||
|
value = source.getProperty(propertyName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!this.propertyValues.containsKey(propertyName)) {
|
if (!this.propertyValues.containsKey(propertyName)) {
|
||||||
this.propertyValues.put(propertyName, new PropertyValue(propertyName,
|
this.propertyValues.put(propertyName, new PropertyValue(propertyName,
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,17 @@ public class PropertySourcesPropertyValuesTests {
|
||||||
.<String, Object> singletonMap("name", "${foo}")));
|
.<String, Object> singletonMap("name", "${foo}")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTypesPreserved() {
|
||||||
|
this.propertySources.replace(
|
||||||
|
"map",
|
||||||
|
new MapPropertySource("map", Collections.<String, Object> singletonMap(
|
||||||
|
"name", 123)));
|
||||||
|
PropertySourcesPropertyValues propertyValues = new PropertySourcesPropertyValues(
|
||||||
|
this.propertySources);
|
||||||
|
assertEquals(123, propertyValues.getPropertyValues()[0].getValue());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSize() {
|
public void testSize() {
|
||||||
PropertySourcesPropertyValues propertyValues = new PropertySourcesPropertyValues(
|
PropertySourcesPropertyValues propertyValues = new PropertySourcesPropertyValues(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue