Return-Path: Delivered-To: apmail-tomcat-dev-archive@www.apache.org Received: (qmail 56744 invoked from network); 7 Jan 2011 22:56:52 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Jan 2011 22:56:52 -0000 Received: (qmail 27336 invoked by uid 500); 7 Jan 2011 22:56:51 -0000 Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org Received: (qmail 27278 invoked by uid 500); 7 Jan 2011 22:56:51 -0000 Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Developers List" Delivered-To: mailing list dev@tomcat.apache.org Received: (qmail 27269 invoked by uid 99); 7 Jan 2011 22:56:51 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Jan 2011 22:56:51 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Jan 2011 22:56:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id BCB9B23888D2; Fri, 7 Jan 2011 22:56:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1056553 - in /tomcat/trunk: java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java java/org/apache/catalina/core/LocalStrings.properties webapps/docs/changelog.xml webapps/docs/config/listeners.xml Date: Fri, 07 Jan 2011 22:56:30 -0000 To: dev@tomcat.apache.org From: slaurent@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110107225630.BCB9B23888D2@eris.apache.org> Author: slaurent Date: Fri Jan 7 22:56:30 2011 New Revision: 1056553 URL: http://svn.apache.org/viewvc?rev=1056553&view=rev Log: bug 50556: improve JreMemoryLeakPreventionListener against leak caused by LdapPoolManager https://issues.apache.org/bugzilla/show_bug.cgi?id=50556 Modified: tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties tomcat/trunk/webapps/docs/changelog.xml tomcat/trunk/webapps/docs/config/listeners.xml Modified: tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java?rev=1056553&r1=1056552&r2=1056553&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/JreMemoryLeakPreventionListener.java Fri Jan 7 22:56:30 2011 @@ -35,6 +35,8 @@ import org.apache.juli.logging.Log; import org.apache.juli.logging.LogFactory; import org.apache.tomcat.util.res.StringManager; +import com.sun.jndi.ldap.LdapPoolManager; + /** * Provide a workaround for known places where the Java Runtime environment can * cause a memory leak or lock files. @@ -162,6 +164,20 @@ public class JreMemoryLeakPreventionList this.xmlParsingProtection = xmlParsingProtection; } + /** + * {@link LdapPoolManager} spawns a thread when it is initialized if the + * system property com.sun.jndi.ldap.connect.pool.timeout is + * greater than 0. + * That thread inherits the context class loader of the current thread, so + * that there my be a web application class loader leak if the web app + * is the first to use {@link LdapPoolManager}. + */ + private boolean ldapPoolProtection = true; + public boolean isLdapPoolProtection() { return ldapPoolProtection; } + public void setLdapPoolProtection(boolean ldapPoolProtection) { + this.ldapPoolProtection = ldapPoolProtection; + } + @Override public void lifecycleEvent(LifecycleEvent event) { // Initialise these classes when Tomcat starts @@ -358,6 +374,22 @@ public class JreMemoryLeakPreventionList e); } } + + if (ldapPoolProtection) { + try { + Class.forName("com.sun.jndi.ldap.LdapPoolManager"); + } catch (ClassNotFoundException e) { + if (System.getProperty("java.vendor").startsWith( + "Sun")) { + log.error(sm.getString( + "jreLeakListener.ldapPoolManagerFail"), e); + } else { + log.debug(sm.getString( + "jreLeakListener.ldapPoolManagerFail"), e); + } + } + } + } finally { Thread.currentThread().setContextClassLoader(loader); } Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1056553&r1=1056552&r2=1056553&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original) +++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Fri Jan 7 22:56:30 2011 @@ -82,6 +82,7 @@ jreLeakListener.gcDaemonFail=Failed to t jreLeakListener.jarUrlConnCacheFail=Failed to disable Jar URL connection caching by default jreLeakListener.xmlParseFail=Error whilst attempting to prevent memory leaks during XML parsing jreLeakListener.authPolicyFail=Error whilst attempting to prevent memory leak in javax.security.auth.Policy class +jreLeakListener.ldapPoolManagerFail=Failed to trigger creation of the com.sun.jndi.ldap.LdapPoolManager class during Tomcat start to prevent possible memory leaks. This is expected on non-Sun JVMs. naming.wsdlFailed=Failed to find wsdl file: {0} naming.bindFailed=Failed to bind object: {0} naming.jmxRegistrationFailed=Failed to register in JMX: {0} Modified: tomcat/trunk/webapps/docs/changelog.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1056553&r1=1056552&r2=1056553&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/changelog.xml (original) +++ tomcat/trunk/webapps/docs/changelog.xml Fri Jan 7 22:56:30 2011 @@ -200,6 +200,13 @@ 50554: Code clean up. (markt) + + 50556: Improve JreMemoryLeakPreventionListener to prevent + a potential class loader leak caused by a thread spawned when the class + com.sun.jndi.ldap.LdapPoolManager is initialized and the + system property com.sun.jndi.ldap.connect.pool.timeout is + set to a value greater than 0. (slaurent) + Modified: tomcat/trunk/webapps/docs/config/listeners.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/listeners.xml?rev=1056553&r1=1056552&r2=1056553&view=diff ============================================================================== --- tomcat/trunk/webapps/docs/config/listeners.xml (original) +++ tomcat/trunk/webapps/docs/config/listeners.xml Fri Jan 7 22:56:30 2011 @@ -270,6 +270,19 @@ service:jmx:rmi://<hostname>:10002 trigger a memory leak on reload. Defaults to true.

+ +

Enables protection so that the PoolCleaner thread started by + com.sun.jndi.ldap.LdapPoolManager does not result in a + memory leak. The thread is started the first time the + LdapPoolManager class is used if the system property + com.sun.jndi.ldap.connect.pool.timeout is set to a value + greater than 0. Without this protection, if a web application uses this + class the PoolCleaner thread will be configured with the thread's + context class loader set to the web application class loader which in + turn will trigger a memory leak on reload. Defaults to + true.

+
+

Enables protection so that usage of the javax.security.auth.login.Configuration class by a web --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org For additional commands, e-mail: dev-help@tomcat.apache.org