Ensure uncaught exceptions are logged into server error log
Normally these go to stdout, but in daemon mode that is usually the useless /dev/null device. Bug: issue 483 Change-Id: Ida8d0c91744410b316ba32834a2307b10bc312f8 Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -91,6 +92,12 @@ public class Daemon extends SiteProgram {
|
||||
@Override
|
||||
public int run() throws Exception {
|
||||
mustHaveValidSite();
|
||||
Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
log.error("Thread " + t.getName() + " threw exception", e);
|
||||
}
|
||||
});
|
||||
|
||||
if (runId != null) {
|
||||
runFile = new File(new File(getSitePath(), "logs"), "gerrit.run");
|
||||
|
Reference in New Issue
Block a user