From b679c8d4d2475aaf0bb90c0e3a4aadfd3ff893d2 Mon Sep 17 00:00:00 2001 From: "Christopher L. Shannon (cshannon)" Date: Tue, 28 Apr 2015 11:49:39 +0000 Subject: [PATCH] Added an uncaught exception handler to ThreadPoolExecutor getExecutor() method to log errors in threads. This resolves https://issues.apache.org/jira/browse/AMQ-5750 This closes #93 --- .../org/apache/activemq/thread/TaskRunnerFactory.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java b/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java index d6b1938dd4..ea1534fb0f 100755 --- a/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java +++ b/activemq-client/src/main/java/org/apache/activemq/thread/TaskRunnerFactory.java @@ -176,7 +176,13 @@ public class TaskRunnerFactory implements Executor { if (threadClassLoader != null) { thread.setContextClassLoader(threadClassLoader); } - + thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { + @Override + public void uncaughtException(final Thread t, final Throwable e) { + LOG.error("Error in thread '{}'", t.getName(), e); + } + }); + LOG.trace("Created thread[{}]: {}", threadName, thread); return thread; }