Skip to content

Commit 81058ca

Browse files
committed
Allow clash in spring.config.name
Remove the recently added slash restriction since Spring Cloud Config Server needs to support names with slashes. See gh-21217
1 parent 559c178 commit 81058ca

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,8 +728,6 @@ private Set<String> asResolvedSet(String value, String fallback) {
728728

729729
private void assertValidConfigName(String name) {
730730
Assert.state(!name.contains("*"), () -> "Config name '" + name + "' cannot contain wildcards");
731-
Assert.state(!name.contains("/") && !name.contains("\\"),
732-
() -> "Config name '" + name + "' cannot contain slashes");
733731
}
734732

735733
private void addLoadedPropertySources() {

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,14 @@ void configNameCannotContainWildcard() {
10511051
.withMessage("Config name '*/application' cannot contain wildcards");
10521052
}
10531053

1054+
@Test
1055+
void configNameCanContainSlash() {
1056+
// Spring Cloud config server depends on this
1057+
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
1058+
"spring.config.location=file:src/test/resources/", "spring.config.name=config/application");
1059+
this.initializer.postProcessEnvironment(this.environment, this.application);
1060+
}
1061+
10541062
@Test
10551063
void directoryLocationsWithMultipleWildcardsShouldThrowException() {
10561064
String location = "file:src/test/resources/config/**/";

0 commit comments

Comments
 (0)