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 50379a49888e..60112d60f008 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 @@ 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 @@ private void onApplicationStartingEvent(ApplicationStartingEvent event) { 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(); } }