From 689d0c8307e1146f2765015f8c9b9dd83be3d96d Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 27 Oct 2020 12:09:17 +0000 Subject: [PATCH] Remove skipping of spring-boot-* projects from DevTools restart triggers Closes gh-23158 --- .../server/DefaultSourceDirectoryUrlFilter.java | 11 ++++------- .../server/DefaultSourceDirectoryUrlFilterTests.java | 12 ------------ .../src/docs/asciidoc/using-spring-boot.adoc | 2 -- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilter.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilter.java index b2fb5a550d2..60647f844c1 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilter.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilter.java @@ -17,9 +17,6 @@ package org.springframework.boot.devtools.restart.server; import java.net.URL; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -40,9 +37,6 @@ public class DefaultSourceDirectoryUrlFilter implements SourceDirectoryUrlFilter private static final Pattern VERSION_PATTERN = Pattern.compile("^-\\d+(?:\\.\\d+)*(?:[.-].+)?$"); - private static final Set SKIPPED_PROJECTS = new HashSet<>(Arrays.asList("spring-boot", - "spring-boot-devtools", "spring-boot-autoconfigure", "spring-boot-actuator", "spring-boot-starter")); - @Override public boolean isMatch(String sourceDirectory, URL url) { String jarName = getJarName(url); @@ -73,10 +67,13 @@ public class DefaultSourceDirectoryUrlFilter implements SourceDirectoryUrlFilter } private boolean isDirectoryMatch(String directory, String jarName) { - if (!jarName.startsWith(directory) || SKIPPED_PROJECTS.contains(directory)) { + if (!jarName.startsWith(directory)) { + System.out.println(jarName + " does not start with " + directory); return false; } + System.out.println(jarName + " starts with " + directory); String version = jarName.substring(directory.length()); + System.out.println("Checking version: " + version); return version.isEmpty() || VERSION_PATTERN.matcher(version).matches(); } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilterTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilterTests.java index 10252cc9688..df9a4fe0b9a 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilterTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/server/DefaultSourceDirectoryUrlFilterTests.java @@ -69,18 +69,6 @@ class DefaultSourceDirectoryUrlFilterTests { doTest("my-module/something/quite/quite/mad/"); } - @Test - void skippedProjects() throws Exception { - String sourceDirectory = "/Users/me/code/spring-boot-samples/spring-boot-sample-devtools"; - URL jarUrl = new URL("jar:file:/Users/me/tmp/spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar!/"); - assertThat(this.filter.isMatch(sourceDirectory, jarUrl)).isTrue(); - URL nestedJarUrl = new URL("jar:file:/Users/me/tmp/spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar!/" - + "lib/spring-boot-1.3.0.BUILD-SNAPSHOT.jar!/"); - assertThat(this.filter.isMatch(sourceDirectory, nestedJarUrl)).isFalse(); - URL fileUrl = new URL("file:/Users/me/tmp/spring-boot-sample-devtools-1.3.0.BUILD-SNAPSHOT.jar"); - assertThat(this.filter.isMatch(sourceDirectory, fileUrl)).isTrue(); - } - private void doTest(String sourcePostfix) throws MalformedURLException { doTest(sourcePostfix, "my-module", true); doTest(sourcePostfix, "my-module-other", false); diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using-spring-boot.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using-spring-boot.adoc index 31ee57fa6e5..d1b49e1fe1b 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using-spring-boot.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/using-spring-boot.adoc @@ -602,8 +602,6 @@ Other devtools features (such as LiveReload and property overrides) can still be NOTE: DevTools relies on the application context's shutdown hook to close it during a restart. It does not work correctly if you have disabled the shutdown hook (`SpringApplication.setRegisterShutdownHook(false)`). -NOTE: When deciding if an entry on the classpath should trigger a restart when it changes, DevTools automatically ignores projects named `spring-boot`, `spring-boot-devtools`, `spring-boot-autoconfigure`, `spring-boot-actuator`, and `spring-boot-starter`. - NOTE: DevTools needs to customize the `ResourceLoader` used by the `ApplicationContext`. If your application provides one already, it is going to be wrapped. Direct override of the `getResource` method on the `ApplicationContext` is not supported.