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:
Chris Beams
2012-11-02 15:02:13 +01:00
parent 74e86fe52f
commit c94bc2e709
3 changed files with 14 additions and 3 deletions

View File

@@ -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());
}