Skip to content

Commit 795100f

Browse files
committed
Merge branch '2.3.x'
See gh-24043
2 parents 8f2de48 + 4a630dc commit 795100f

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ private void load(PropertySourceLoader loader, String location, Profile profile,
507507
}
508508
continue;
509509
}
510-
if (resource.isFile() && hasHiddenPathElement(resource)) {
510+
if (resource.isFile() && isPatternLocation(location) && hasHiddenPathElement(resource)) {
511511
if (this.logger.isTraceEnabled()) {
512512
StringBuilder description = getDescription("Skipped location with hidden path element ",
513513
location, resource, profile);
@@ -573,7 +573,7 @@ private String getLocationName(String locationReference, Resource resource) {
573573

574574
private Resource[] getResources(String locationReference) {
575575
try {
576-
if (locationReference.contains("*")) {
576+
if (isPatternLocation(locationReference)) {
577577
return getResourcesFromPatternLocationReference(locationReference);
578578
}
579579
return new Resource[] { this.resourceLoader.getResource(locationReference) };
@@ -583,6 +583,10 @@ private Resource[] getResources(String locationReference) {
583583
}
584584
}
585585

586+
private boolean isPatternLocation(String location) {
587+
return location.contains("*");
588+
}
589+
586590
private Resource[] getResourcesFromPatternLocationReference(String locationReference) throws IOException {
587591
String directoryPath = locationReference.substring(0, locationReference.indexOf("*/"));
588592
Resource resource = this.resourceLoader.getResource(directoryPath);

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,6 +1086,16 @@ void locationsWithWildcardDirectoriesShouldIgnoreHiddenDirectories() {
10861086
assertThat(this.environment.getProperty("fourth.property")).isNull();
10871087
}
10881088

1089+
@Test
1090+
void nonWildcardHiddenDirectoryLocationShouldNotBeIgnored() {
1091+
String location = "file:src/test/resources/config/..hidden/";
1092+
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
1093+
"spring.config.location=" + location);
1094+
this.initializer.setSearchNames("testproperties");
1095+
this.initializer.postProcessEnvironment(this.environment, this.application);
1096+
assertThat(this.environment.getProperty("fourth.property")).isNotNull();
1097+
}
1098+
10891099
@Test
10901100
void locationsWithWildcardDirectoriesShouldLoadAllFilesThatMatch() {
10911101
String location = "file:src/test/resources/config/*/";

0 commit comments

Comments
 (0)