From edcde28ecdfa56cd55ed68dd4e2a6a0566e5aaa7 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 9 May 2019 11:04:26 +0200 Subject: [PATCH] Set UncaughtExceptionHandler for CACHED_EXECUTOR_SERVICE In order to avoid uncaught exceptions from terminating the program (SMACK-896). --- .../java/org/jivesoftware/smack/AbstractXMPPConnection.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index fe82c07f6..d65fb0b24 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -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; } });