Merge pull request #28495 from Artur-

* pr/28495:
  Polish "Log the reason that led Devtools to restart the app"
  Log the reason that led Devtools to restart the app

Closes gh-28495
pull/29200/head
Stephane Nicoll 3 years ago
commit c3abf96d1f

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2022 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,6 +20,9 @@ import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@ -94,6 +97,8 @@ public class LocalDevToolsAutoConfiguration {
@ConditionalOnProperty(prefix = "spring.devtools.restart", name = "enabled", matchIfMissing = true) @ConditionalOnProperty(prefix = "spring.devtools.restart", name = "enabled", matchIfMissing = true)
static class RestartConfiguration { static class RestartConfiguration {
private static final Log restarterLogger = LogFactory.getLog(Restarter.class);
private final DevToolsProperties properties; private final DevToolsProperties properties;
RestartConfiguration(DevToolsProperties properties) { RestartConfiguration(DevToolsProperties properties) {
@ -105,6 +110,10 @@ public class LocalDevToolsAutoConfiguration {
FileSystemWatcherFactory fileSystemWatcherFactory) { FileSystemWatcherFactory fileSystemWatcherFactory) {
return (event) -> { return (event) -> {
if (event.isRestartRequired()) { if (event.isRestartRequired()) {
if (restarterLogger.isDebugEnabled()) {
restarterLogger.debug(
"Application restart required due to the following changes: " + event.getChangeSet());
}
Restarter.getInstance().restart(new FileWatchingFailureHandler(fileSystemWatcherFactory)); Restarter.getInstance().restart(new FileWatchingFailureHandler(fileSystemWatcherFactory));
} }
}; };

Loading…
Cancel
Save