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
This commit is contained in:
Christopher L. Shannon (cshannon) 2015-04-28 11:49:39 +00:00 committed by Timothy Bish
parent 16a1e2b686
commit b679c8d4d2
1 changed files with 7 additions and 1 deletions

View File

@ -176,6 +176,12 @@ public class TaskRunnerFactory implements Executor {
if (threadClassLoader != null) { if (threadClassLoader != null) {
thread.setContextClassLoader(threadClassLoader); 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); LOG.trace("Created thread[{}]: {}", threadName, thread);
return thread; return thread;