Skip to content

Commit b81c004

Browse files
committed
Polish "Log the reason that led Devtools to restart the app"
See gh-28495
1 parent 0769b33 commit b81c004

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfiguration.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,9 @@
2020
import java.net.URL;
2121
import java.util.List;
2222

23+
import org.apache.commons.logging.Log;
24+
import org.apache.commons.logging.LogFactory;
25+
2326
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
2427
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2528
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -94,6 +97,8 @@ LiveReloadServerEventListener liveReloadServerEventListener(OptionalLiveReloadSe
9497
@ConditionalOnProperty(prefix = "spring.devtools.restart", name = "enabled", matchIfMissing = true)
9598
static class RestartConfiguration {
9699

100+
private static final Log restarterLogger = LogFactory.getLog(Restarter.class);
101+
97102
private final DevToolsProperties properties;
98103

99104
RestartConfiguration(DevToolsProperties properties) {
@@ -105,6 +110,10 @@ ApplicationListener<ClassPathChangedEvent> restartingClassPathChangedEventListen
105110
FileSystemWatcherFactory fileSystemWatcherFactory) {
106111
return (event) -> {
107112
if (event.isRestartRequired()) {
113+
if (restarterLogger.isDebugEnabled()) {
114+
restarterLogger.debug(
115+
"Application restart required due to the following changes: " + event.getChangeSet());
116+
}
108117
Restarter.getInstance().restart(new FileWatchingFailureHandler(fileSystemWatcherFactory));
109118
}
110119
};

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/classpath/ClassPathFileChangeListener.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818

1919
import java.util.Set;
2020

21-
import org.apache.commons.logging.Log;
22-
import org.apache.commons.logging.LogFactory;
23-
2421
import org.springframework.boot.devtools.filewatch.ChangedFile;
2522
import org.springframework.boot.devtools.filewatch.ChangedFiles;
2623
import org.springframework.boot.devtools.filewatch.FileChangeListener;
@@ -38,8 +35,6 @@
3835
*/
3936
class ClassPathFileChangeListener implements FileChangeListener {
4037

41-
private static final Log logger = LogFactory.getLog(ClassPathFileChangeListener.class);
42-
4338
private final ApplicationEventPublisher eventPublisher;
4439

4540
private final ClassPathRestartStrategy restartStrategy;
@@ -65,9 +60,6 @@ class ClassPathFileChangeListener implements FileChangeListener {
6560
@Override
6661
public void onChange(Set<ChangedFiles> changeSet) {
6762
boolean restart = isRestartRequired(changeSet);
68-
if (restart && logger.isDebugEnabled()) {
69-
logger.debug("Restarting dev tools due to changes in the following files: " + changeSet);
70-
}
7163
publishEvent(new ClassPathChangedEvent(this, changeSet, restart));
7264
}
7365

0 commit comments

Comments
 (0)