Skip to content

Commit 6fe30a8

Browse files
committed
Merge branch '2.2.x'
Closes gh-21175
2 parents 2bfba4a + 36b082e commit 6fe30a8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import org.springframework.core.io.Resource;
6464
import org.springframework.core.io.ResourceLoader;
6565
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
66+
import org.springframework.core.io.support.ResourcePatternResolver;
6667
import org.springframework.core.io.support.SpringFactoriesLoader;
6768
import org.springframework.util.Assert;
6869
import org.springframework.util.CollectionUtils;
@@ -656,6 +657,8 @@ private Set<String> getSearchLocations(String propertyName) {
656657
for (String path : asResolvedSet(this.environment.getProperty(propertyName), null)) {
657658
if (!path.contains("$")) {
658659
path = StringUtils.cleanPath(path);
660+
Assert.state(!path.startsWith(ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX),
661+
"Classpath wildard patterns cannot be used as a search location");
659662
if (!ResourceUtils.isUrl(path)) {
660663
path = ResourceUtils.FILE_URL_PREFIX + path;
661664
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,15 @@ void absoluteResourceDefaultsToFile() {
710710
matchingPropertySource("applicationConfig: [file:" + location.replace(File.separatorChar, '/') + "]"));
711711
}
712712

713+
@Test
714+
void classpathWildcardResourceThrowsException() {
715+
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
716+
"spring.config.location=classpath*:override.properties");
717+
assertThatIllegalStateException()
718+
.isThrownBy(() -> this.initializer.postProcessEnvironment(this.environment, this.application))
719+
.withMessage("Classpath wildard patterns cannot be used as a search location");
720+
}
721+
713722
@Test
714723
void propertySourceAnnotation() {
715724
SpringApplication application = new SpringApplication(WithPropertySource.class);

0 commit comments

Comments
 (0)