Skip to content

Commit 110c36e

Browse files
committed
Merge branch '2.4.x' into main
Closes gh-26610
2 parents 8a3f835 + 80610fa commit 110c36e

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/Profiles.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,16 @@ private List<String> asReversedList(List<String> list) {
148148
return reversed;
149149
}
150150

151-
private List<String> asUniqueItemList(Collection<String> strings) {
152-
return asUniqueItemList(strings, null);
151+
private List<String> asUniqueItemList(Collection<String> profiles) {
152+
return asUniqueItemList(profiles, null);
153153
}
154154

155-
private List<String> asUniqueItemList(Collection<String> strings, Collection<String> additional) {
156-
LinkedHashSet<String> uniqueItems = new LinkedHashSet<>(strings);
155+
private List<String> asUniqueItemList(Collection<String> profiles, Collection<String> additional) {
156+
LinkedHashSet<String> uniqueItems = new LinkedHashSet<>();
157157
if (!CollectionUtils.isEmpty(additional)) {
158158
uniqueItems.addAll(additional);
159159
}
160+
uniqueItems.addAll(profiles);
160161
return Collections.unmodifiableList(new ArrayList<>(uniqueItems));
161162
}
162163

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,15 +592,14 @@ void addProfiles() {
592592
}
593593

594594
@Test
595-
void addProfilesOrder() {
595+
void additionalProfilesOrderedBeforeActiveProfiles() {
596596
SpringApplication application = new SpringApplication(ExampleConfig.class);
597597
application.setWebApplicationType(WebApplicationType.NONE);
598598
application.setAdditionalProfiles("foo");
599599
ConfigurableEnvironment environment = new StandardEnvironment();
600600
application.setEnvironment(environment);
601601
this.context = application.run("--spring.profiles.active=bar,spam");
602-
// Since Boot 2.4 additional should always be last
603-
assertThat(environment.getActiveProfiles()).containsExactly("bar", "spam", "foo");
602+
assertThat(environment.getActiveProfiles()).containsExactly("foo", "bar", "spam");
604603
}
605604

606605
@Test

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentPostProcessorIntegrationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ void runWhenTwoProfilesSetProgrammaticallyLoadsWithPreservedProfileOrder() {
308308
void runWhenProfilesPresentBeforeConfigFileProcessingAugmentsProfileActivatedByConfigFile() {
309309
this.application.setAdditionalProfiles("other");
310310
ConfigurableApplicationContext context = this.application.run("--spring.config.name=enableprofile");
311-
assertThat(context.getEnvironment().getActiveProfiles()).containsExactly("myprofile", "other");
311+
assertThat(context.getEnvironment().getActiveProfiles()).containsExactly("other", "myprofile");
312312
String property = context.getEnvironment().getProperty("other.property");
313313
assertThat(property).isEqualTo("fromotherpropertiesfile");
314314
property = context.getEnvironment().getProperty("the.property");

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ProfilesTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ void getActiveWithProfileGroups() {
143143
@Test
144144
void getActiveWhenHasAdditionalIncludesAdditional() {
145145
MockEnvironment environment = new MockEnvironment();
146-
environment.setProperty("spring.profiles.active", "a,b,c");
146+
environment.setProperty("spring.profiles.active", "d,e,f");
147147
Binder binder = Binder.get(environment);
148-
Profiles profiles = new Profiles(environment, binder, Arrays.asList("d", "e", "f"));
148+
Profiles profiles = new Profiles(environment, binder, Arrays.asList("a", "b", "c"));
149149
assertThat(profiles.getActive()).containsExactly("a", "b", "c", "d", "e", "f");
150150
}
151151

0 commit comments

Comments
 (0)