diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java index 29c7d360ac..1e2b9b1ed9 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -222,8 +223,8 @@ public class AutoConfigurationImportSelector String name = entry.getKey(); Object value = entry.getValue(); if (name.isEmpty() || name.startsWith("[") && value != null) { - excludes.addAll( - StringUtils.commaDelimitedListToSet(String.valueOf(value))); + excludes.addAll(new HashSet(Arrays.asList(StringUtils + .tokenizeToStringArray(String.valueOf(value), ",")))); } } return excludes; diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java index 9be2c9ad08..a84b28b29b 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelectorTests.java @@ -130,11 +130,15 @@ public class AutoConfigurationImportSelectorTests { this.environment.setProperty("spring.autoconfigure.exclude", FreeMarkerAutoConfiguration.class.getName() + "," + MustacheAutoConfiguration.class.getName()); - String[] imports = selectImports(BasicEnableAutoConfiguration.class); - assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2); - assertThat(this.importSelector.getLastEvent().getExclusions()).contains( - FreeMarkerAutoConfiguration.class.getName(), - MustacheAutoConfiguration.class.getName()); + testSeveralPropertyExclusionsAreApplied(); + } + + @Test + public void severalPropertyExclusionsAreAppliedWithExtraSpaces() { + this.environment.setProperty("spring.autoconfigure.exclude", + FreeMarkerAutoConfiguration.class.getName() + " , " + + MustacheAutoConfiguration.class.getName() + " "); + testSeveralPropertyExclusionsAreApplied(); } @Test @@ -143,6 +147,10 @@ public class AutoConfigurationImportSelectorTests { FreeMarkerAutoConfiguration.class.getName()); this.environment.setProperty("spring.autoconfigure.exclude[1]", MustacheAutoConfiguration.class.getName()); + testSeveralPropertyExclusionsAreApplied(); + } + + private void testSeveralPropertyExclusionsAreApplied() { String[] imports = selectImports(BasicEnableAutoConfiguration.class); assertThat(imports).hasSize(getAutoConfigurationClassNames().size() - 2); assertThat(this.importSelector.getLastEvent().getExclusions()).contains(