mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-5417 - use proper classloader in TaskRunnerFactory
This commit is contained in:
parent
adafdfe97d
commit
dffccb1c7d
|
@ -1202,6 +1202,7 @@ public class BrokerService implements Service {
|
|||
if (this.taskRunnerFactory == null) {
|
||||
this.taskRunnerFactory = new TaskRunnerFactory("ActiveMQ BrokerService["+getBrokerName()+"] Task", getTaskRunnerPriority(), true, 1000,
|
||||
isDedicatedTaskRunner());
|
||||
this.taskRunnerFactory.setThreadClassLoader(this.getClass().getClassLoader());
|
||||
}
|
||||
return this.taskRunnerFactory;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ public class TaskRunnerFactory implements Executor {
|
|||
private final AtomicBoolean initDone = new AtomicBoolean(false);
|
||||
private int maxThreadPoolSize = Integer.MAX_VALUE;
|
||||
private RejectedExecutionHandler rejectedTaskHandler = null;
|
||||
private ClassLoader threadClassLoader;
|
||||
|
||||
public TaskRunnerFactory() {
|
||||
this("ActiveMQ Task");
|
||||
|
@ -172,6 +173,9 @@ public class TaskRunnerFactory implements Executor {
|
|||
Thread thread = new Thread(runnable, threadName);
|
||||
thread.setDaemon(daemon);
|
||||
thread.setPriority(priority);
|
||||
if (threadClassLoader != null) {
|
||||
thread.setContextClassLoader(threadClassLoader);
|
||||
}
|
||||
|
||||
LOG.trace("Created thread[{}]: {}", threadName, thread);
|
||||
return thread;
|
||||
|
@ -239,6 +243,10 @@ public class TaskRunnerFactory implements Executor {
|
|||
this.maxThreadPoolSize = maxThreadPoolSize;
|
||||
}
|
||||
|
||||
public void setThreadClassLoader(ClassLoader threadClassLoader) {
|
||||
this.threadClassLoader = threadClassLoader;
|
||||
}
|
||||
|
||||
public RejectedExecutionHandler getRejectedTaskHandler() {
|
||||
return rejectedTaskHandler;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue