Ignore unresolvable nested placeholders

The NamePatternEnvironmentFilter used to throw an exception if
placeholders in property values could not be resolved.

Fixes gh-8510
This commit is contained in:
Madhura Bhave
2017-03-06 16:06:42 -08:00
parent f5aeac3658
commit 67068fc83d
2 changed files with 20 additions and 1 deletions

View File

@@ -102,6 +102,16 @@ public class EnvironmentMvcEndpointTests {
.andExpect(content().string(containsString("\"fool\":\"baz\"")));
}
@Test
public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
map.put("my.foo", "${my.bar}");
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
.addFirst(new MapPropertySource("unresolved-placeholder", map));
this.mvc.perform(get("/env/my.*")).andExpect(status().isOk())
.andExpect(content().string(containsString("\"my.foo\":\"${my.bar}\"")));
}
@Configuration
@Import({ JacksonAutoConfiguration.class,
HttpMessageConvertersAutoConfiguration.class, WebMvcAutoConfiguration.class,