Skip to content

Commit 7f32fa6

Browse files
committed
Allow 'on-profile' in profile specific files
Restore the ability to use `spring.config.activate.on-profile` or `spring.profiles` in profile specific files. Closes gh-24990
1 parent d06407e commit 7f32fa6

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ public class InvalidConfigDataPropertyException extends ConfigDataException {
5252
errors.add(Profiles.INCLUDE_PROFILES);
5353
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
5454
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME));
55-
errors.add(ConfigurationPropertyName.of("spring.config.activate.on-profile"));
56-
errors.add(ConfigurationPropertyName.of("spring.profiles"));
5755
PROFILE_SPECIFIC_ERRORS = Collections.unmodifiableSet(errors);
5856
}
5957

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,15 @@ void runWhenHasWildcardLocationLoadsFromAllMatchingLocations() {
680680
assertThat(environment.getProperty("second.property")).isEqualTo("ball");
681681
}
682682

683+
@Test // gh-24990
684+
void runWhenHasProfileSpecificFileWithActiveOnProfileProperty() {
685+
ConfigurableApplicationContext context = this.application
686+
.run("--spring.config.name=application-activate-on-profile-in-profile-specific-file");
687+
ConfigurableEnvironment environment = context.getEnvironment();
688+
assertThat(environment.getProperty("test1")).isEqualTo("test1");
689+
assertThat(environment.getProperty("test2")).isEqualTo("test2");
690+
}
691+
683692
private Condition<ConfigurableEnvironment> matchingPropertySource(final String sourceName) {
684693
return new Condition<ConfigurableEnvironment>("environment containing property source " + sourceName) {
685694

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ void throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException() {
125125
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.profiles.include");
126126
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.profiles.active");
127127
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.profiles.default");
128-
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.config.activate.on-profile");
129-
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.profiles");
130128
}
131129

132130
@Test
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test1=test1
2+
#---
3+
spring.config.activate.on-profile=other
4+
test2=test2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spring.profiles.active=test,other

0 commit comments

Comments
 (0)