add uncaughtexception handler

This commit is contained in:
alex.zheng
2017-09-06 12:07:50 +08:00
parent a1cf292baa
commit 041cbf04c7

View File

@@ -20,6 +20,10 @@ public class CanalLauncher {
public static void main(String[] args) throws Throwable {
try {
logger.info("## set default uncaught exception handler");
setGlobalUncaughtExceptionHandler();
logger.info("## load canal configurations");
String conf = System.getProperty("canal.conf", "classpath:canal.properties");
Properties properties = new Properties();
if (conf.startsWith(CLASSPATH_URL_PREFIX)) {
@@ -52,4 +56,13 @@ public class CanalLauncher {
System.exit(0);
}
}
private static void setGlobalUncaughtExceptionHandler() {
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
logger.error("UnCaughtException", e);
}
});
}
}