Merge branch '2.4.x'

Closes gh-25348
pull/25369/head
Madhura Bhave 4 years ago
commit 6fa7c6ac21

@ -43,6 +43,8 @@ public class InvalidConfigDataPropertyException extends ConfigDataException {
Map<ConfigurationPropertyName, ConfigurationPropertyName> warnings = new LinkedHashMap<>();
warnings.put(ConfigurationPropertyName.of("spring.profiles"),
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);
}
@ -50,8 +52,11 @@ public class InvalidConfigDataPropertyException extends ConfigDataException {
static {
Set<ConfigurationPropertyName> errors = new LinkedHashSet<>();
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 + "[0]"));
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);
}

@ -642,9 +642,10 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
}
@Test
void runWhenHasIncludedProfilesWithProfileSpecificFileThrowsException() {
assertThatExceptionOfType(InvalidConfigDataPropertyException.class).isThrownBy(() -> this.application
.run("--spring.config.name=application-include-profiles-in-profile-specific-file"));
void runWhenHasIncludedProfilesWithListSyntaxWithProfileSpecificDocumentThrowsException() {
assertThatExceptionOfType(InvalidConfigDataPropertyException.class).isThrownBy(() -> this.application.run(
"--spring.config.name=application-include-profiles-list-in-profile-specific-file",
"--spring.profiles.active=test"));
}
@Test

@ -169,6 +169,16 @@ class InvalidConfigDataPropertyExceptionTests {
+ "'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 {
@Override

Loading…
Cancel
Save