Remove default profile during environment merge
This change fixes a minor bug with the implementation of ConfigurableEnvironment#merge, introduced in SPR-9444. During a merge of two environments A and B, where A has default profiles [prod] and B has default profiles [default] (the so-called 'reserved default profile'), B would complete the merge process having a collection of profiles reading [default, prod], which is incorrect. This commit explicitly ensure's that B's reserved default profile is removed if A has a set of default profiles greater than zero. If A consists only of [default], B will inherit it during the merge correctly; if A consists of [p1, p2], B will result in [p1, p2] as well; if B consists of [p1] and A of [p2, p3], B will result in [p1, p2, p3] post-merge. Issue: SPR-9761, SPR-9444
This commit is contained in:
parent
f963d0f190
commit
9f8d219146
|
|
@ -409,10 +409,13 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
|
||||||
for (String profile : parent.getActiveProfiles()) {
|
for (String profile : parent.getActiveProfiles()) {
|
||||||
this.activeProfiles.add(profile);
|
this.activeProfiles.add(profile);
|
||||||
}
|
}
|
||||||
|
if (parent.getDefaultProfiles().length > 0) {
|
||||||
|
this.defaultProfiles.remove(RESERVED_DEFAULT_PROFILE_NAME);
|
||||||
for (String profile : parent.getDefaultProfiles()) {
|
for (String profile : parent.getDefaultProfiles()) {
|
||||||
this.defaultProfiles.add(profile);
|
this.defaultProfiles.add(profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue