Respect spring.profiles.active in #addActiveProfile
Prior to this commit, calls to ConfigurableEnvironment#addActiveProfile would cause any active profile values provided via the "spring.profiles.active" property to be ignored. Now these two mechanisms can be used in conjunction and work as expected. Issue: SPR-9944
This commit is contained in:
@@ -240,7 +240,8 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
Assert.notNull(profiles, "Profile array must not be null");
|
||||
this.activeProfiles.clear();
|
||||
for (String profile : profiles) {
|
||||
addActiveProfile(profile);
|
||||
validateProfile(profile);
|
||||
this.activeProfiles.add(profile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,9 +250,11 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||
this.logger.debug(format("Activating profile '%s'", profile));
|
||||
}
|
||||
validateProfile(profile);
|
||||
doGetActiveProfiles();
|
||||
this.activeProfiles.add(profile);
|
||||
}
|
||||
|
||||
|
||||
public String[] getDefaultProfiles() {
|
||||
return StringUtils.toStringArray(doGetDefaultProfiles());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user