Set UncaughtExceptionHandler for CACHED_EXECUTOR_SERVICE

In order to avoid uncaught exceptions from terminating the
program (SMACK-896).
This commit is contained in:
Florian Schmaus 2019-05-09 11:04:26 +02:00
parent 7980e2cedb
commit edcde28ecd
1 changed files with 6 additions and 0 deletions

View File

@ -294,6 +294,12 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
Thread thread = new Thread(runnable);
thread.setName("Smack Cached Executor");
thread.setDaemon(true);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
LOGGER.log(Level.WARNING, t + " encountered uncaught exception", e);
}
});
return thread;
}
});