diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java index b8dab15000..e818bdc9d2 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java @@ -161,20 +161,31 @@ public class EnableAutoConfigurationImportSelector private void checkExcludedClasses(List configurations, Set exclusions) { - StringBuilder message = new StringBuilder(); + List invalidExcludes = new ArrayList(); for (String exclusion : exclusions) { if (ClassUtils.isPresent(exclusion, getClass().getClassLoader()) && !configurations.contains(exclusion)) { - message.append("\t- ").append(exclusion).append(String.format("%n")); + invalidExcludes.add(exclusion); } } - if (!message.toString().isEmpty()) { - throw new IllegalStateException(String.format( - "The following classes could not be excluded because they are" - + " not auto-configuration classes:%n%s", - message.toString())); + if (!invalidExcludes.isEmpty()) { + handleInvalidExcludes(invalidExcludes); } + } + /** + * Handle any invalid excludes that have been specified. + * @param invalidExcludes the list of invalid excludes (will always have at least on + * element) + */ + protected void handleInvalidExcludes(List invalidExcludes) { + StringBuilder message = new StringBuilder(); + for (String exclude : invalidExcludes) { + message.append("\t- ").append(exclude).append(String.format("%n")); + } + throw new IllegalStateException(String + .format("The following classes could not be excluded because they are" + + " not auto-configuration classes:%n%s", message)); } /** diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java index 90abf076f8..44021075a9 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java @@ -146,4 +146,9 @@ class ImportAutoConfigurationImportSelector return super.getOrder() - 1; } + @Override + protected void handleInvalidExcludes(List invalidExcludes) { + // Ignore for test + } + } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelectorTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelectorTests.java index 60f274ecbb..bb0587b01c 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelectorTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelectorTests.java @@ -116,6 +116,15 @@ public class ImportAutoConfigurationImportSelectorTests { assertThat(imports).containsOnly(FreeMarkerAutoConfiguration.class.getName()); } + @Test + public void exclusionsWithoutImport() throws Exception { + AnnotationMetadata annotationMetadata = new SimpleMetadataReaderFactory() + .getMetadataReader(ExclusionWithoutImport.class.getName()) + .getAnnotationMetadata(); + String[] imports = this.importSelector.selectImports(annotationMetadata); + assertThat(imports).containsOnly(FreeMarkerAutoConfiguration.class.getName()); + } + @Test public void exclusionsAliasesAreApplied() throws Exception { AnnotationMetadata annotationMetadata = new SimpleMetadataReaderFactory() @@ -149,6 +158,12 @@ public class ImportAutoConfigurationImportSelectorTests { } + @ImportOne + @ImportAutoConfiguration(exclude = ThymeleafAutoConfiguration.class) + static class ExclusionWithoutImport { + + } + @SelfAnnotating static class ImportWithSelfAnnotatingAnnotation { diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java index 79df32a07f..5fd384e9f2 100644 --- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java +++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/livereload/LiveReloadServerTests.java @@ -83,9 +83,8 @@ public class LiveReloadServerTests { @Test public void triggerReload() throws Exception { LiveReloadWebSocketHandler handler = connect(); - handler.setExpectedMessageCount(1); this.server.triggerReload(); - handler.awaitMessages(); + Thread.sleep(200); this.server.stop(); assertThat(handler.getMessages().get(0)) .contains("http://livereload.com/protocols/official-7"); @@ -208,8 +207,6 @@ public class LiveReloadServerTests { private final CountDownLatch helloLatch = new CountDownLatch(2); - private CountDownLatch messagesLatch; - private final List messages = new ArrayList(); private int pongCount; @@ -229,19 +226,12 @@ public class LiveReloadServerTests { Thread.sleep(200); } - public void setExpectedMessageCount(int count) { - this.messagesLatch = new CountDownLatch(count); - } - @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { if (message.getPayload().contains("hello")) { this.helloLatch.countDown(); } - if (this.messagesLatch != null) { - this.messagesLatch.countDown(); - } this.messages.add(message.getPayload()); } @@ -265,10 +255,6 @@ public class LiveReloadServerTests { this.session.close(); } - public void awaitMessages() throws InterruptedException { - this.messagesLatch.await(1, TimeUnit.MINUTES); - } - public List getMessages() { return this.messages; } diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script index cba5329854..a36f3d3ba1 100755 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/resources/org/springframework/boot/loader/tools/launch.script @@ -212,9 +212,9 @@ force_stop() { do_force_stop() { kill -9 "$1" &> /dev/null || { echoRed "Unable to kill process $1"; return 1; } - for i in $(seq 1 60); do + for i in $(seq 1 $STOP_WAIT_TIME); do isRunning "$1" || { echoGreen "Stopped [$1]"; rm -f "$2"; return 0; } - [[ $i -eq 30 ]] && kill -9 "$1" &> /dev/null + [[ $i -eq STOP_WAIT_TIME/2 ]] && kill "$1" &> /dev/null sleep 1 done echoRed "Unable to kill process $1"; @@ -271,7 +271,7 @@ status) run) run "$@"; exit $?;; *) - echo "Usage: $0 {start|stop|restart|force-reload|status|run}"; exit 1; + echo "Usage: $0 {start|stop|force-stop|restart|force-reload|status|run}"; exit 1; esac exit 0