Author: kkolinko
Date: Mon May 12 01:38:31 2014
New Revision: 1593878

URL: http://svn.apache.org/r1593878
Log:
Merged r1593877 from tomcat/trunk:
- ThreadLocalLeakPreventionListener: Trigger thread renewals for 
StandardContext only. (Do not trigger them for FailedContext and similar).
- StandardThreadExecutor: Pass 'threadRenewalDelay' to the thread pool 
executor. Otherwise this setting configured at initialization time is 
effectively ignored.
- Improve documentation.
Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java
    
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
    tomcat/tc7.0.x/trunk/webapps/docs/config/executor.xml
    tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1593877

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java?rev=1593878&r1=1593877&r2=1593878&view=diff
==============================================================================
--- 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java 
(original)
+++ 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardThreadExecutor.java 
Mon May 12 01:38:31 2014
@@ -119,6 +119,7 @@ public class StandardThreadExecutor exte
         taskqueue = new TaskQueue(maxQueueSize);
         TaskThreadFactory tf = new 
TaskThreadFactory(namePrefix,daemon,getThreadPriority());
         executor = new ThreadPoolExecutor(getMinSpareThreads(), 
getMaxThreads(), maxIdleTime, TimeUnit.MILLISECONDS,taskqueue, tf);
+        executor.setThreadRenewalDelay(threadRenewalDelay);
         if (prestartminSpareThreads) {
             executor.prestartAllCoreThreads();
         }

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java?rev=1593878&r1=1593877&r2=1593878&view=diff
==============================================================================
--- 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
 (original)
+++ 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/ThreadLocalLeakPreventionListener.java
 Mon May 12 01:38:31 2014
@@ -194,10 +194,10 @@ public class ThreadLocalLeakPreventionLi
     private void stopIdleThreads(Context context) {
         if (serverStopping) return;
 
-        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 not configured to do it.");
             return;
         }
 

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1593878&r1=1593877&r2=1593878&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon May 12 01:38:31 2014
@@ -168,6 +168,11 @@
         <bug>56492</bug>: Avoid eclipse debugger pausing on uncaught exceptions
         when tomcat renews its threads. (slaurent)
       </add>
+      <fix>
+        Minor fixes to <code>ThreadLocalLeakPreventionListener</code>. Do not
+        trigger threads renewal for failed contexts. Do not ignore
+        <code>threadRenewalDelay</code> setting. Improve documentation. 
(kkolinko)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">

Modified: tomcat/tc7.0.x/trunk/webapps/docs/config/executor.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/config/executor.xml?rev=1593878&r1=1593877&r2=1593878&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/config/executor.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/config/executor.xml Mon May 12 01:38:31 
2014
@@ -112,9 +112,11 @@
           the default is <code>false</code></p>
     </attribute>
     <attribute name="threadRenewalDelay" required="false">
-      <p>After a context is stopped, threads in the pool are renewed. To avoid 
renewing all threads at the same time,
-        this delay is observed between 2 threads being renewed. Value is in 
ms, default value is 1000ms.
-        If negative, threads are not renewed.</p>
+      <p>(long) If a <a 
href="listeners.html">ThreadLocalLeakPreventionListener</a> is configured,
+        it will notify this executor about stopped contexts.
+        After a context is stopped, threads in the pool are renewed. To avoid 
renewing all threads at the same time,
+        this option sets a delay between renewal of any 2 threads. The value 
is in ms,
+        default value is <code>1000</code> ms. If value is negative, threads 
are not renewed.</p>
     </attribute>
   </attributes>
 

Modified: tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml?rev=1593878&r1=1593877&r2=1593878&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/config/listeners.xml Mon May 12 01:38:31 
2014
@@ -334,10 +334,12 @@
   <subsection name="ThreadLocal Leak Prevention Listener - 
org.apache.catalina.core.ThreadLocalLeakPreventionListener">
 
     <p>The <strong>ThreadLocal Leak Prevention Listener</strong> triggers the
-    renewal of threads in Executor pools when a
+    renewal of threads in <a href="executor.html">Executor</a> pools when a
     <a href="context.html">Context</a> is being stopped to avoid thread-local
     related memory leaks. Active threads will be renewed one by one when they
-    come back to the pool after executing their task.</p>
+    come back to the pool after executing their task. The renewal happens
+    only for contexts that have their 
<code>renewThreadsWhenStoppingContext</code>
+    attribute set to <code>true</code>.</p>
 
     <p>This listener must only be nested within <a 
href="server.html">Server</a>
     elements.</p>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to