Author: slaurent Date: Thu Dec 9 18:55:04 2010 New Revision: 1044083 URL: http://svn.apache.org/viewvc?rev=1044083&view=rev Log: bug 49159: Improve ThreadLocal memory leak clean-up https://issues.apache.org/bugzilla/show_bug.cgi?id=49159
some formatting after discussion over the list (operator at the end of line, unnecessary cast) Modified: tomcat/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java Modified: tomcat/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java?rev=1044083&r1=1044082&r2=1044083&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java Thu Dec 9 18:55:04 2010 @@ -71,8 +71,8 @@ public class ThreadLocalLeakPreventionLi public void lifecycleEvent(LifecycleEvent event) { try { Lifecycle lifecycle = event.getLifecycle(); - if (Lifecycle.AFTER_START_EVENT.equals(event.getType()) - && lifecycle instanceof Server) { + if (Lifecycle.AFTER_START_EVENT.equals(event.getType()) && + lifecycle instanceof Server) { // when the server starts, we register ourself as listener for // all context // as well as container event listener so that we know when new @@ -81,8 +81,8 @@ public class ThreadLocalLeakPreventionLi registerListenersForServer(server); } - if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType()) - && lifecycle instanceof Context) { + if (Lifecycle.AFTER_STOP_EVENT.equals(event.getType()) && + lifecycle instanceof Context) { stopIdleThreads((Context) lifecycle); } } catch (Exception e) { @@ -145,8 +145,8 @@ public class ThreadLocalLeakPreventionLi protected void processContainerAddChild(Container parent, Container child) { if (log.isDebugEnabled()) - log.debug("Process addChild[parent=" + parent + ",child=" + child - + "]"); + log.debug("Process addChild[parent=" + parent + ",child=" + child + + "]"); if (child instanceof Context) { registerContextListener((Context) child); @@ -158,22 +158,18 @@ public class ThreadLocalLeakPreventionLi } - protected void processContainerRemoveChild(Container parent, + protected void processContainerRemoveChild(Container parent, Container child) { if (log.isDebugEnabled()) - log.debug("Process removeChild[parent=" + parent + ",child=" - + child + "]"); + log.debug("Process removeChild[parent=" + parent + ",child=" + + child + "]"); if (child instanceof Context) { Context context = (Context) child; context.removeLifecycleListener(this); - } else if (child instanceof Host) { - Host host = (Host) child; - host.removeContainerListener(this); - } else if (child instanceof Engine) { - Engine engine = (Engine) child; - engine.removeContainerListener(this); + } else if (child instanceof Host || child instanceof Engine) { + child.removeContainerListener(this); } } @@ -186,9 +182,10 @@ public class ThreadLocalLeakPreventionLi * of its parent Service. */ private void stopIdleThreads(Context context) { - if (context instanceof StandardContext && + if (context instanceof StandardContext && !((StandardContext) context).getRenewThreadsWhenStoppingContext()) { - log.debug("Not renewing threads when the context is stopping, it is configured not to do it."); + log.debug("Not renewing threads when the context is stopping, " + + "it is configured not to do it."); return; } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org