[jboss-jira] [JBoss JIRA] Updated: (JBCOMMON-41) ClassLoader leak in BasicThreadPool

Brian Stansberry (JIRA) jira-events at lists.jboss.org
Sat Feb 9 15:41:34 EST 2008


     [ http://jira.jboss.com/jira/browse/JBCOMMON-41?page=all ]

Brian Stansberry updated JBCOMMON-41:
-------------------------------------

    JBoss Forum Reference: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=129688

> 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

        



More information about the jboss-jira mailing list