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) {
|
if (this.taskRunnerFactory == null) {
|
||||||
this.taskRunnerFactory = new TaskRunnerFactory("ActiveMQ BrokerService["+getBrokerName()+"] Task", getTaskRunnerPriority(), true, 1000,
|
this.taskRunnerFactory = new TaskRunnerFactory("ActiveMQ BrokerService["+getBrokerName()+"] Task", getTaskRunnerPriority(), true, 1000,
|
||||||
isDedicatedTaskRunner());
|
isDedicatedTaskRunner());
|
||||||
|
this.taskRunnerFactory.setThreadClassLoader(this.getClass().getClassLoader());
|
||||||
}
|
}
|
||||||
return this.taskRunnerFactory;
|
return this.taskRunnerFactory;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ public class TaskRunnerFactory implements Executor {
|
||||||
private final AtomicBoolean initDone = new AtomicBoolean(false);
|
private final AtomicBoolean initDone = new AtomicBoolean(false);
|
||||||
private int maxThreadPoolSize = Integer.MAX_VALUE;
|
private int maxThreadPoolSize = Integer.MAX_VALUE;
|
||||||
private RejectedExecutionHandler rejectedTaskHandler = null;
|
private RejectedExecutionHandler rejectedTaskHandler = null;
|
||||||
|
private ClassLoader threadClassLoader;
|
||||||
|
|
||||||
public TaskRunnerFactory() {
|
public TaskRunnerFactory() {
|
||||||
this("ActiveMQ Task");
|
this("ActiveMQ Task");
|
||||||
|
@ -172,6 +173,9 @@ public class TaskRunnerFactory implements Executor {
|
||||||
Thread thread = new Thread(runnable, threadName);
|
Thread thread = new Thread(runnable, threadName);
|
||||||
thread.setDaemon(daemon);
|
thread.setDaemon(daemon);
|
||||||
thread.setPriority(priority);
|
thread.setPriority(priority);
|
||||||
|
if (threadClassLoader != null) {
|
||||||
|
thread.setContextClassLoader(threadClassLoader);
|
||||||
|
}
|
||||||
|
|
||||||
LOG.trace("Created thread[{}]: {}", threadName, thread);
|
LOG.trace("Created thread[{}]: {}", threadName, thread);
|
||||||
return thread;
|
return thread;
|
||||||
|
@ -239,6 +243,10 @@ public class TaskRunnerFactory implements Executor {
|
||||||
this.maxThreadPoolSize = maxThreadPoolSize;
|
this.maxThreadPoolSize = maxThreadPoolSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setThreadClassLoader(ClassLoader threadClassLoader) {
|
||||||
|
this.threadClassLoader = threadClassLoader;
|
||||||
|
}
|
||||||
|
|
||||||
public RejectedExecutionHandler getRejectedTaskHandler() {
|
public RejectedExecutionHandler getRejectedTaskHandler() {
|
||||||
return rejectedTaskHandler;
|
return rejectedTaskHandler;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue