commit
6fa7c6ac21
|
@ -43,6 +43,8 @@ public class InvalidConfigDataPropertyException extends ConfigDataException {
|
||||||
Map<ConfigurationPropertyName, ConfigurationPropertyName> warnings = new LinkedHashMap<>();
|
Map<ConfigurationPropertyName, ConfigurationPropertyName> warnings = new LinkedHashMap<>();
|
||||||
warnings.put(ConfigurationPropertyName.of("spring.profiles"),
|
warnings.put(ConfigurationPropertyName.of("spring.profiles"),
|
||||||
ConfigurationPropertyName.of("spring.config.activate.on-profile"));
|
ConfigurationPropertyName.of("spring.config.activate.on-profile"));
|
||||||
|
warnings.put(ConfigurationPropertyName.of("spring.profiles[0]"),
|
||||||
|
ConfigurationPropertyName.of("spring.config.activate.on-profile"));
|
||||||
WARNINGS = Collections.unmodifiableMap(warnings);
|
WARNINGS = Collections.unmodifiableMap(warnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +52,11 @@ public class InvalidConfigDataPropertyException extends ConfigDataException {
|
||||||
static {
|
static {
|
||||||
Set<ConfigurationPropertyName> errors = new LinkedHashSet<>();
|
Set<ConfigurationPropertyName> errors = new LinkedHashSet<>();
|
||||||
errors.add(Profiles.INCLUDE_PROFILES);
|
errors.add(Profiles.INCLUDE_PROFILES);
|
||||||
|
errors.add(Profiles.INCLUDE_PROFILES.append("[0]"));
|
||||||
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
|
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME));
|
||||||
|
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME + "[0]"));
|
||||||
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME));
|
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME));
|
||||||
|
errors.add(ConfigurationPropertyName.of(AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME + "[0]"));
|
||||||
PROFILE_SPECIFIC_ERRORS = Collections.unmodifiableSet(errors);
|
PROFILE_SPECIFIC_ERRORS = Collections.unmodifiableSet(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -642,9 +642,10 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void runWhenHasIncludedProfilesWithProfileSpecificFileThrowsException() {
|
void runWhenHasIncludedProfilesWithListSyntaxWithProfileSpecificDocumentThrowsException() {
|
||||||
assertThatExceptionOfType(InvalidConfigDataPropertyException.class).isThrownBy(() -> this.application
|
assertThatExceptionOfType(InvalidConfigDataPropertyException.class).isThrownBy(() -> this.application.run(
|
||||||
.run("--spring.config.name=application-include-profiles-in-profile-specific-file"));
|
"--spring.config.name=application-include-profiles-list-in-profile-specific-file",
|
||||||
|
"--spring.profiles.active=test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -169,6 +169,16 @@ class InvalidConfigDataPropertyExceptionTests {
|
||||||
+ "'spring.config.activate.on-profile' [origin: \"spring.profiles\" from property source \"mockProperties\"]");
|
+ "'spring.config.activate.on-profile' [origin: \"spring.profiles\" from property source \"mockProperties\"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void throwOrWarnWhenHasWarningPropertyWithListSyntaxLogsWarning() {
|
||||||
|
MockPropertySource propertySource = new MockPropertySource();
|
||||||
|
propertySource.setProperty("spring.profiles[0]", "a");
|
||||||
|
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor.ofExisting(propertySource);
|
||||||
|
InvalidConfigDataPropertyException.throwOrWarn(this.logger, contributor);
|
||||||
|
verify(this.logger).warn("Property 'spring.profiles[0]' is invalid and should be replaced with "
|
||||||
|
+ "'spring.config.activate.on-profile' [origin: \"spring.profiles[0]\" from property source \"mockProperties\"]");
|
||||||
|
}
|
||||||
|
|
||||||
private static class TestConfigDataResource extends ConfigDataResource {
|
private static class TestConfigDataResource extends ConfigDataResource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
spring:
|
||||||
|
profiles:
|
||||||
|
include:
|
||||||
|
- p
|
Loading…
Reference in New Issue