[
http://jira.jboss.com/jira/browse/JBCOMMON-41?page=all ]
Brian Stansberry closed JBCOMMON-41.
------------------------------------
Resolution: Done
Added a pluggable ClassLoaderSource property, from which the pool gets a CL to set as TCCL
when creating a pool thread or returning one to the pool. To ensure backwards
compatibility, if no ClassLoaderSource is injected, the handling of the TCCL is unchanged
from previous releases.
ClassLoader leak in BasicThreadPool
-----------------------------------
Key: JBCOMMON-41
URL:
http://jira.jboss.com/jira/browse/JBCOMMON-41
Project: JBoss Common
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: common-core
Affects Versions: 2.2.3.GA
Reporter: Brian Stansberry
Assigned To: Brian Stansberry
Fix For: 2.2.4.GA
BasicThreadPool leaks the TCCL of whatever thread is executing when it needs to add
threads to the pool. When it's ThreadPoolExecutor needs another thread to handle a
task, it calls BasicThreadPool.ThreadPoolThreadFactory.newThread(Runnable) which does
this:
String threadName = BasicThreadPool.this.toString() + "-" +
lastThreadNumber.incrementAndGet();
Thread thread = new Thread(threadGroup, runnable, threadName);
thread.setDaemon(true);
return thread;
The new thread will inherit the TCCL from the old one. Nothing ever clears the TCCL from
the pooled thread.
A couple possible solutions come to mind:
1) Set the new thread's TCCL to null in ThreadPoolThreadFactory.newThread()
2) Subclass ThreadPoolExecutor, override the afterExecute() method, and set the TCCL to
null there. The afterExecute() method is invoked at the completion of each task.
The latter seems preferable, or perhaps both. A question is whether they should set the
TCCL to BasicThreadPool.class.getClassLoader() instead of null. That doesn't sound
right though.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira