Commit 795100f2 authored by Andy Wilkinson's avatar Andy Wilkinson

Merge branch '2.3.x'

See gh-24043
parents 8f2de48f 4a630dc7
......@@ -507,7 +507,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
continue;
}
if (resource.isFile() && hasHiddenPathElement(resource)) {
if (resource.isFile() && isPatternLocation(location) && hasHiddenPathElement(resource)) {
if (this.logger.isTraceEnabled()) {
StringBuilder description = getDescription("Skipped location with hidden path element ",
location, resource, profile);
......@@ -573,7 +573,7 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
private Resource[] getResources(String locationReference) {
try {
if (locationReference.contains("*")) {
if (isPatternLocation(locationReference)) {
return getResourcesFromPatternLocationReference(locationReference);
}
return new Resource[] { this.resourceLoader.getResource(locationReference) };
......@@ -583,6 +583,10 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor,
}
}
private boolean isPatternLocation(String location) {
return location.contains("*");
}
private Resource[] getResourcesFromPatternLocationReference(String locationReference) throws IOException {
String directoryPath = locationReference.substring(0, locationReference.indexOf("*/"));
Resource resource = this.resourceLoader.getResource(directoryPath);
......
......@@ -1086,6 +1086,16 @@ class ConfigFileApplicationListenerTests {
assertThat(this.environment.getProperty("fourth.property")).isNull();
}
@Test
void nonWildcardHiddenDirectoryLocationShouldNotBeIgnored() {
String location = "file:src/test/resources/config/..hidden/";
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
"spring.config.location=" + location);
this.initializer.setSearchNames("testproperties");
this.initializer.postProcessEnvironment(this.environment, this.application);
assertThat(this.environment.getProperty("fourth.property")).isNotNull();
}
@Test
void locationsWithWildcardDirectoriesShouldLoadAllFilesThatMatch() {
String location = "file:src/test/resources/config/*/";
......
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