Skip to content

Commit e76605f

Browse files
eiselemswilkinsona
authored andcommitted
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
1 parent 35bd4cf commit e76605f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/RestartApplicationListener.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
package org.springframework.boot.devtools.restart;
1818

19+
import org.apache.commons.logging.Log;
20+
import org.apache.commons.logging.LogFactory;
21+
1922
import org.springframework.boot.context.event.ApplicationFailedEvent;
2023
import org.springframework.boot.context.event.ApplicationPreparedEvent;
2124
import org.springframework.boot.context.event.ApplicationReadyEvent;
@@ -35,10 +38,12 @@
3538
public class RestartApplicationListener
3639
implements ApplicationListener<ApplicationEvent>, Ordered {
3740

38-
private int order = HIGHEST_PRECEDENCE;
39-
4041
private static final String ENABLED_PROPERTY = "spring.devtools.restart.enabled";
4142

43+
private static final Log logger = LogFactory.getLog(RestartApplicationListener.class);
44+
45+
private int order = HIGHEST_PRECEDENCE;
46+
4247
@Override
4348
public void onApplicationEvent(ApplicationEvent event) {
4449
if (event instanceof ApplicationStartingEvent) {
@@ -63,10 +68,17 @@ private void onApplicationStartingEvent(ApplicationStartingEvent event) {
6368
if (enabled == null || Boolean.parseBoolean(enabled)) {
6469
String[] args = event.getArgs();
6570
DefaultRestartInitializer initializer = new DefaultRestartInitializer();
66-
boolean restartOnInitialize = !AgentReloader.isActive();
71+
boolean restartOnInitialize = true;
72+
if (AgentReloader.isActive()) {
73+
logger.info(
74+
"Restart disabled due to an agent-based reloader being active");
75+
restartOnInitialize = false;
76+
}
6777
Restarter.initialize(args, false, initializer, restartOnInitialize);
6878
}
6979
else {
80+
logger.info("Restart disabled due to System property '" + ENABLED_PROPERTY
81+
+ "' set to false");
7082
Restarter.disable();
7183
}
7284
}

0 commit comments

Comments
 (0)