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:
Phillip Webb
2015-11-10 00:09:28 -08:00
parent e8b28796d9
commit a530221213
6 changed files with 151 additions and 16 deletions

View File

@@ -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(

View File

@@ -50,6 +50,7 @@ class RestartLauncher extends Thread {
}
catch (Throwable ex) {
this.error = ex;
getUncaughtExceptionHandler().uncaughtException(this, ex);
}
}

View File

@@ -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);