Commit 06494e06 authored by Phillip Webb's avatar Phillip Webb

Consistent property source ordering with names

Update ConfigFileApplicationListener so that custom names and custom
locations use consistent ordering. i.e. earlier items take precedence
(same as @ProperySource).
parent 52c42059
......@@ -369,12 +369,12 @@ public class ConfigFileApplicationListener implements
private void addLoadCandidatesFromSearchLocations(
ConfigurableEnvironment environment, Set<String> candidates) {
String[] names = StringUtils.commaDelimitedListToStringArray(environment
.resolvePlaceholders(ConfigFileApplicationListener.this.names));
for (String location : ConfigFileApplicationListener.this.searchLocations) {
for (String extension : new String[] { ".properties", ".yml" }) {
for (String name : StringUtils
.commaDelimitedListToStringArray(environment
.resolvePlaceholders(ConfigFileApplicationListener.this.names))) {
candidates.add(location + name + extension);
for (int i = names.length - 1; i >= 0; i--) {
candidates.add(location + names[i] + extension);
}
}
}
......
......@@ -108,7 +108,7 @@ public class ConfigFileApplicationListenerTests {
@Test
public void loadTwoPropertiesFiles() throws Exception {
this.initializer.setNames("testproperties,moreproperties");
this.initializer.setNames("moreproperties,testproperties");
this.initializer.onApplicationEvent(this.event);
String property = this.environment.getProperty("my.property");
assertThat(property, equalTo("frommorepropertiesfile"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment