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
This commit is contained in:
parent
d06407ec0a
commit
7f32fa6723
|
@ -52,8 +52,6 @@ public class InvalidConfigDataPropertyException extends ConfigDataException {
|
|||
errors.add(Profiles.INCLUDE_PROFILES);
|
||||
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
|
||||
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME));
|
||||
errors.add(ConfigurationPropertyName.of("spring.config.activate.on-profile"));
|
||||
errors.add(ConfigurationPropertyName.of("spring.profiles"));
|
||||
PROFILE_SPECIFIC_ERRORS = Collections.unmodifiableSet(errors);
|
||||
}
|
||||
|
||||
|
|
|
@ -680,6 +680,15 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
|
|||
assertThat(environment.getProperty("second.property")).isEqualTo("ball");
|
||||
}
|
||||
|
||||
@Test // gh-24990
|
||||
void runWhenHasProfileSpecificFileWithActiveOnProfileProperty() {
|
||||
ConfigurableApplicationContext context = this.application
|
||||
.run("--spring.config.name=application-activate-on-profile-in-profile-specific-file");
|
||||
ConfigurableEnvironment environment = context.getEnvironment();
|
||||
assertThat(environment.getProperty("test1")).isEqualTo("test1");
|
||||
assertThat(environment.getProperty("test2")).isEqualTo("test2");
|
||||
}
|
||||
|
||||
private Condition<ConfigurableEnvironment> matchingPropertySource(final String sourceName) {
|
||||
return new Condition<ConfigurableEnvironment>("environment containing property source " + sourceName) {
|
||||
|
||||
|
|
|
@ -125,8 +125,6 @@ class InvalidConfigDataPropertyExceptionTests {
|
|||
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.profiles.include");
|
||||
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.profiles.active");
|
||||
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.profiles.default");
|
||||
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.config.activate.on-profile");
|
||||
throwOrWarnWhenWhenHasInvalidProfileSpecificPropertyThrowsException("spring.profiles");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
test1=test1
|
||||
#---
|
||||
spring.config.activate.on-profile=other
|
||||
test2=test2
|
|
@ -0,0 +1 @@
|
|||
spring.profiles.active=test,other
|
Loading…
Reference in New Issue