Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 67717 invoked from network); 5 Jun 2010 17:52:15 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Jun 2010 17:52:15 -0000 Received: (qmail 76680 invoked by uid 500); 5 Jun 2010 17:52:15 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 76607 invoked by uid 500); 5 Jun 2010 17:52:15 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 76599 invoked by uid 99); 5 Jun 2010 17:52:15 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jun 2010 17:52:15 +0000 X-ASF-Spam-Status: No, hits=-1500.4 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Jun 2010 17:52:14 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o55Hpssd023507 for ; Sat, 5 Jun 2010 17:51:54 GMT Message-ID: <6719658.199501275760314515.JavaMail.jira@thor> Date: Sat, 5 Jun 2010 13:51:54 -0400 (EDT) From: "Sylvain Laurent (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (POOL-161) ContextClassLoader problems for the Evictor thread In-Reply-To: <1308923012.257591268605647221.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/POOL-161?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12875921#action_12875921 ] Sylvain Laurent commented on POOL-161: -------------------------------------- 1. Correct 2. No. Mark's patch fixes the CCL when the TimerThread is started. The patch I provided allows to have the ObjectFactory called with a different CCL just for the duration of the call. So there are no leak problems involved here for case #2, just a use case in a multi-classloader environment 3. The issue I raised did not ask to review the whole commons-pool usage in multi-classloader environment, I just proposed to fix a use case I encountered. Actually I first discovered the leak and then found out about the issue about multi-classloader usage... So, If my patch were applied, I would consider the issue as totally fixed. > ContextClassLoader problems for the Evictor thread > -------------------------------------------------- > > Key: POOL-161 > URL: https://issues.apache.org/jira/browse/POOL-161 > Project: Commons Pool > Issue Type: Bug > Affects Versions: 1.5.4 > Reporter: Sylvain Laurent > Fix For: 2.0 > > Attachments: patch_Evictor_CCL.txt, TestGenericObjectPoolClassLoader.patch.txt > > > Since a single Timer is used for several GenericObjectPool instances, this may create classloader issues and a memory leak of one classloader : > Let's imagine the following scenario : > - commons-pool.jar is in the classpath of a webapp container (e.g. tomcat). > - 2 webapps A and B are deployed, each creating an instance of GenericObjectPool for its own usage. > - each webapp makes use of the idle object evictor and sets a positive number for minIdle > - first, webapp A instantiates its GenericObjectPool. Since this is the first TimerTask to be created, the Timer instance is created, thus creating a Thread whose ContextClassLoader is the current one, that is webapp A's ContextClassLoader. > The TimerTask properly creates instances of idle objects in the pool, making use of the ObjectFactory provided by A. > - then B instantiates its GenericObjectPool. A new TimerTask is created, and it tries to invoke the ObjectFactory provided by B. But when it needs a class that only exists in B webapp, it cannot find it because the ContextClassLoader of the Timer Thread is A's classloader. > Other side effect : if webapp A is undeployed, but B is still running, then A's webappClassLoader cannot be GCed because the Timer Thread keeps a strong reference to A's classloader (as its context classloader). -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.