diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java index c1659c1af4c..e28bba5bd27 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnClassCondition.java @@ -16,6 +16,7 @@ package org.springframework.boot.autoconfigure.condition; +import java.util.Collections; import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -101,9 +102,7 @@ class OnClassCondition extends SpringBootCondition { private void addAll(List list, List itemsToAdd) { if (itemsToAdd != null) { for (Object item : itemsToAdd) { - for (String arrayItem : (String[]) item) { - list.add(arrayItem.toString()); - } + Collections.addAll(list, (String[]) item); } } } diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 098d8e4450b..1d7cb617861 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -455,12 +455,9 @@ public class SpringApplication { * @see #configureEnvironment(ConfigurableEnvironment, String[]) */ protected void configureProfiles(ConfigurableEnvironment environment, String[] args) { - Set profiles = new LinkedHashSet(); environment.getActiveProfiles(); // ensure they are initialized // But these ones should go first (last wins in a property key clash) - for (String profile : this.profiles) { - profiles.add(profile); - } + Set profiles = new LinkedHashSet(this.profiles); profiles.addAll(Arrays.asList(environment.getActiveProfiles())); environment.setActiveProfiles(profiles.toArray(new String[profiles.size()])); } diff --git a/spring-boot/src/test/java/org/springframework/boot/context/web/SpringBootServletInitializerTests.java b/spring-boot/src/test/java/org/springframework/boot/context/web/SpringBootServletInitializerTests.java index 96c80438e14..34a0f525ac4 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/web/SpringBootServletInitializerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/web/SpringBootServletInitializerTests.java @@ -16,6 +16,7 @@ package org.springframework.boot.context.web; +import java.util.Collections; import java.util.LinkedHashSet; import java.util.Set; @@ -73,9 +74,7 @@ public class SpringBootServletInitializerTests { private Matcher> equalToSet(Object... items) { Set set = new LinkedHashSet(); - for (Object item : items) { - set.add(item); - } + Collections.addAll(set, items); return equalTo(set); }