From d6fe4b9a6aa219f931343cd531faf5ac20f518f4 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 13 Dec 2017 12:18:59 +0100 Subject: [PATCH] Polish --- .../boot/devtools/restart/Restarter.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java index c9b7d3f388..c0cb5fbfdd 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/Restarter.java @@ -23,7 +23,6 @@ import java.net.URL; import java.util.Arrays; import java.util.Collection; import java.util.HashMap; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; @@ -273,11 +272,10 @@ public class Restarter { private Throwable doStart() throws Exception { Assert.notNull(this.mainClassName, "Unable to find the main class to restart"); - ClassLoader parent = this.applicationClassLoader; URL[] urls = this.urls.toArray(new URL[this.urls.size()]); ClassLoaderFiles updatedFiles = new ClassLoaderFiles(this.classLoaderFiles); - ClassLoader classLoader = new RestartClassLoader(parent, urls, updatedFiles, - this.logger); + ClassLoader classLoader = new RestartClassLoader(this.applicationClassLoader, + urls, updatedFiles, this.logger); if (this.logger.isDebugEnabled()) { this.logger.debug("Starting application " + this.mainClassName + " with URLs " + Arrays.asList(urls)); @@ -361,14 +359,8 @@ public class Restarter { } if (instance instanceof Map) { Map map = ((Map) instance); - for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) { - Object value = iterator.next(); - if (value instanceof Class && ((Class) value) - .getClassLoader() instanceof RestartClassLoader) { - iterator.remove(); - } - - } + map.keySet().removeIf(value -> value instanceof Class && ((Class) value) + .getClassLoader() instanceof RestartClassLoader); } } @@ -505,7 +497,7 @@ public class Restarter { /** * Initialize restart support. See - * {@link #initialize(String[], boolean, RestartInitializer)} for details. + * {@link #initialize(String[], boolean, RestartInitializer, boolean)} for details. * @param args main application arguments * @param forceReferenceCleanup if forcing of soft/weak reference should happen on * @param initializer the restart initializer @@ -559,7 +551,7 @@ public class Restarter { * Set the restarter instance (useful for testing). * @param instance the instance to set */ - final static void setInstance(Restarter instance) { + static void setInstance(Restarter instance) { synchronized (INSTANCE_MONITOR) { Restarter.instance = instance; }