From e76605ff757f7e8bb4c00484c29f7a2a18fff532 Mon Sep 17 00:00:00 2001 From: Marcus Eisele Date: Fri, 19 Oct 2018 23:06:23 +0200 Subject: [PATCH] Add Log Output when DevTools restart is disabled This covers the cases when: * An Java agent based reloader (e.g. JRebel) is being used * The reloader was disabled by using a system property See gh-14807 --- .../restart/RestartApplicationListener.java | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/RestartApplicationListener.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/RestartApplicationListener.java index 50379a4988..60112d60f0 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/RestartApplicationListener.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/RestartApplicationListener.java @@ -16,6 +16,9 @@ package org.springframework.boot.devtools.restart; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.springframework.boot.context.event.ApplicationFailedEvent; import org.springframework.boot.context.event.ApplicationPreparedEvent; import org.springframework.boot.context.event.ApplicationReadyEvent; @@ -35,10 +38,12 @@ import org.springframework.core.Ordered; public class RestartApplicationListener implements ApplicationListener, Ordered { - private int order = HIGHEST_PRECEDENCE; - private static final String ENABLED_PROPERTY = "spring.devtools.restart.enabled"; + private static final Log logger = LogFactory.getLog(RestartApplicationListener.class); + + private int order = HIGHEST_PRECEDENCE; + @Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ApplicationStartingEvent) { @@ -63,10 +68,17 @@ public class RestartApplicationListener if (enabled == null || Boolean.parseBoolean(enabled)) { String[] args = event.getArgs(); DefaultRestartInitializer initializer = new DefaultRestartInitializer(); - boolean restartOnInitialize = !AgentReloader.isActive(); + boolean restartOnInitialize = true; + if (AgentReloader.isActive()) { + logger.info( + "Restart disabled due to an agent-based reloader being active"); + restartOnInitialize = false; + } Restarter.initialize(args, false, initializer, restartOnInitialize); } else { + logger.info("Restart disabled due to System property '" + ENABLED_PROPERTY + + "' set to false"); Restarter.disable(); } }