File tree 2 files changed +13
-0
lines changed
spring-boot-project/spring-boot/src
main/java/org/springframework/boot/context/config
test/java/org/springframework/boot/context/config
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 62
62
import org .springframework .core .io .DefaultResourceLoader ;
63
63
import org .springframework .core .io .Resource ;
64
64
import org .springframework .core .io .ResourceLoader ;
65
+ import org .springframework .core .io .support .ResourcePatternResolver ;
65
66
import org .springframework .core .io .support .SpringFactoriesLoader ;
66
67
import org .springframework .util .Assert ;
67
68
import org .springframework .util .CollectionUtils ;
@@ -618,6 +619,8 @@ private Set<String> getSearchLocations(String propertyName) {
618
619
for (String path : asResolvedSet (this .environment .getProperty (propertyName ), null )) {
619
620
if (!path .contains ("$" )) {
620
621
path = StringUtils .cleanPath (path );
622
+ Assert .state (!path .startsWith (ResourcePatternResolver .CLASSPATH_ALL_URL_PREFIX ),
623
+ "Classpath wildard patterns cannot be used as a search location" );
621
624
if (!ResourceUtils .isUrl (path )) {
622
625
path = ResourceUtils .FILE_URL_PREFIX + path ;
623
626
}
Original file line number Diff line number Diff line change 63
63
import org .springframework .util .StringUtils ;
64
64
65
65
import static org .assertj .core .api .Assertions .assertThat ;
66
+ import static org .assertj .core .api .Assertions .assertThatIllegalStateException ;
66
67
67
68
/**
68
69
* Tests for {@link ConfigFileApplicationListener}.
@@ -648,6 +649,15 @@ public void absoluteResourceDefaultsToFile() {
648
649
matchingPropertySource ("applicationConfig: [file:" + location .replace (File .separatorChar , '/' ) + "]" ));
649
650
}
650
651
652
+ @ Test
653
+ public void classpathWildcardResourceThrowsException () {
654
+ TestPropertySourceUtils .addInlinedPropertiesToEnvironment (this .environment ,
655
+ "spring.config.location=classpath*:override.properties" );
656
+ assertThatIllegalStateException ()
657
+ .isThrownBy (() -> this .initializer .postProcessEnvironment (this .environment , this .application ))
658
+ .withMessage ("Classpath wildard patterns cannot be used as a search location" );
659
+ }
660
+
651
661
@ Test
652
662
public void propertySourceAnnotation () {
653
663
SpringApplication application = new SpringApplication (WithPropertySource .class );
You can’t perform that action at this time.
0 commit comments