Ensure startup failures are only logged once
Update SpringApplication so that startup exceptions are only logged once. A custom UncaughtExceptionHandler is now used when running in the main thread to suppress errors that have already been logged. Fixes gh-4423
This commit is contained in:
@@ -42,7 +42,6 @@ class FileWatchingFailureHandler implements FailureHandler {
|
||||
|
||||
@Override
|
||||
public Outcome handle(Throwable failure) {
|
||||
failure.printStackTrace();
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
FileSystemWatcher watcher = this.fileSystemWatcherFactory.getFileSystemWatcher();
|
||||
watcher.addSourceFolders(
|
||||
|
||||
@@ -50,6 +50,7 @@ class RestartLauncher extends Thread {
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
this.error = ex;
|
||||
getUncaughtExceptionHandler().uncaughtException(this, ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -271,10 +271,7 @@ public class Restarter {
|
||||
return;
|
||||
}
|
||||
if (failureHandler.handle(error) == Outcome.ABORT) {
|
||||
if (error instanceof Exception) {
|
||||
throw (Exception) error;
|
||||
}
|
||||
throw new Exception(error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
|
||||
Reference in New Issue
Block a user