tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r950164 - in /tomcat/trunk: java/org/apache/catalina/core/StandardContext.java java/org/apache/catalina/loader/WebappClassLoader.java java/org/apache/catalina/loader/WebappLoader.java webapps/docs/config/context.xml
Date Tue, 01 Jun 2010 16:59:14 GMT
Author: markt
Date: Tue Jun  1 16:59:14 2010
New Revision: 950164

URL: http://svn.apache.org/viewvc?rev=950164&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48971
Make stopping of TimerThreads optional and disabled by default

Modified:
    tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
    tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java
    tomcat/trunk/webapps/docs/config/context.xml

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=950164&r1=950163&r2=950164&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Tue Jun  1 16:59:14 2010
@@ -759,9 +759,16 @@ public class StandardContext extends Con
      * instability. As such, enabling this should be viewed as an option of last
      * resort in a development environment and is not recommended in a
      * production environment. If not specified, the default value of
-     * <code>false</code> will be used. 
+     * <code>false</code> will be used.
      */
     private boolean clearReferencesStopThreads = false;
+
+    /**
+     * Should Tomcat attempt to terminate any {@link java.util.TimerThread}s
+     * that have been started by the web application? If not specified, the
+     * default value of <code>false</code> will be used.
+     */
+    private boolean clearReferencesStopTimerThreads = false;
     
     /**
      * Should Tomcat attempt to clear any ThreadLocal objects that are instances
@@ -2309,6 +2316,31 @@ public class StandardContext extends Con
 
 
     /**
+     * Return the clearReferencesStopTimerThreads flag for this Context.
+     */
+    public boolean getClearReferencesStopTimerThreads() {
+        return (this.clearReferencesStopTimerThreads);
+    }
+
+
+    /**
+     * Set the clearReferencesStopTimerThreads feature for this Context.
+     *
+     * @param clearReferencesStopTimerThreads The new flag value
+     */
+    public void setClearReferencesStopTimerThreads(
+            boolean clearReferencesStopTimerThreads) {
+
+        boolean oldClearReferencesStopTimerThreads =
+            this.clearReferencesStopTimerThreads;
+        this.clearReferencesStopTimerThreads = clearReferencesStopTimerThreads;
+        support.firePropertyChange("clearReferencesStopTimerThreads",
+                                   oldClearReferencesStopTimerThreads,
+                                   this.clearReferencesStopTimerThreads);
+    }
+
+
+    /**
      * Return the clearReferencesThreadLocals flag for this Context.
      */
     public boolean getClearReferencesThreadLocals() {

Modified: tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java?rev=950164&r1=950163&r2=950164&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java (original)
+++ tomcat/trunk/java/org/apache/catalina/loader/WebappClassLoader.java Tue Jun  1 16:59:14
2010
@@ -444,13 +444,18 @@ public class WebappClassLoader
      * instability. As such, enabling this should be viewed as an option of last
      * resort in a development environment and is not recommended in a
      * production environment. If not specified, the default value of
-     * <code>false</code> will be used. Note that instances of
-     * java.util.TimerThread will always be terminate since a safe method exists
-     * to do so.
+     * <code>false</code> will be used.
      */
     private boolean clearReferencesStopThreads = false;
 
     /**
+     * Should Tomcat attempt to terminate any {@link java.util.TimerThread}s
+     * that have been started by the web application? If not specified, the
+     * default value of <code>false</code> will be used.
+     */
+    private boolean clearReferencesStopTimerThreads = false;
+
+    /**
      * Should Tomcat attempt to clear any ThreadLocal objects that are instances
      * of classes loaded by this class loader. Failure to remove any such
      * objects will result in a memory leak on web application stop, undeploy or
@@ -707,6 +712,25 @@ public class WebappClassLoader
 
 
      /**
+      * Return the clearReferencesStopTimerThreads flag for this Context.
+      */
+     public boolean getClearReferencesStopTimerThreads() {
+         return (this.clearReferencesStopTimerThreads);
+     }
+
+
+     /**
+      * Set the clearReferencesStopTimerThreads feature for this Context.
+      *
+      * @param clearReferencesStopTimerThreads The new flag value
+      */
+     public void setClearReferencesStopTimerThreads(
+             boolean clearReferencesStopTimerThreads) {
+         this.clearReferencesStopTimerThreads = clearReferencesStopTimerThreads;
+     }
+
+
+     /**
       * Return the clearReferencesLogFactoryRelease flag for this Context.
       */
      public boolean getClearReferencesLogFactoryRelease() {
@@ -714,6 +738,16 @@ public class WebappClassLoader
      }
 
 
+     /**
+      * Set the clearReferencesLogFactoryRelease feature for this Context.
+      *
+      * @param clearReferencesLogFactoryRelease The new flag value
+      */
+     public void setClearReferencesLogFactoryRelease(
+             boolean clearReferencesLogFactoryRelease) {
+         this.clearReferencesLogFactoryRelease =
+             clearReferencesLogFactoryRelease;
+     }
 
 
      /**
@@ -735,18 +769,6 @@ public class WebappClassLoader
      }
 
 
-     /**
-      * Set the clearReferencesLogFactoryRelease feature for this Context.
-      *
-      * @param clearReferencesLogFactoryRelease The new flag value
-      */
-     public void setClearReferencesLogFactoryRelease(
-             boolean clearReferencesLogFactoryRelease) {
-         this.clearReferencesLogFactoryRelease =
-             clearReferencesLogFactoryRelease;
-     }
-
-
     // ------------------------------------------------------- Reloader Methods
 
 
@@ -2152,9 +2174,10 @@ public class WebappClassLoader
                         continue;
                     }
                    
-                    // TimerThread is not normally visible
+                    // TimerThread can be stopped safely so treat separately
                     if (thread.getClass().getName().equals(
-                            "java.util.TimerThread")) {
+                            "java.util.TimerThread") &&
+                            clearReferencesStopTimerThreads) {
                         clearReferencesStopTimerThread(thread);
                         continue;
                     }

Modified: tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java?rev=950164&r1=950163&r2=950164&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java (original)
+++ tomcat/trunk/java/org/apache/catalina/loader/WebappLoader.java Tue Jun  1 16:59:14 2010
@@ -576,6 +576,8 @@ public class WebappLoader extends Lifecy
                         ((StandardContext) container).getClearReferencesStatic());
                 classLoader.setClearReferencesStopThreads(
                         ((StandardContext) container).getClearReferencesStopThreads());
+                classLoader.setClearReferencesStopTimerThreads(
+                        ((StandardContext) container).getClearReferencesStopTimerThreads());
                 classLoader.setClearReferencesThreadLocals(
                         ((StandardContext) container).getClearReferencesThreadLocals());
             }

Modified: tomcat/trunk/webapps/docs/config/context.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/context.xml?rev=950164&r1=950163&r2=950164&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/context.xml (original)
+++ tomcat/trunk/webapps/docs/config/context.xml Tue Jun  1 16:59:14 2010
@@ -434,6 +434,14 @@
         default value of <code>false</code> will be used.</p>
       </attribute>
 
+      <attribute name="clearReferencesStopTimerThreads" required = "false">
+        <p>If <code>true</code>, Tomcat attempts to terminate
+        <code>java.util.Timer</code>threads that have been started by the web
+        application. Unlike standard threads, timer threads can be stopped
+        safely although there may still be side-effects for the application. If
+        not specified, the default value of <code>false</code> will be used.</p>
+      </attribute>
+
       <attribute name="clearReferencesThreadLocals" required="false">
         <p>If <code>true</code>, Tomcat attempts to clear any ThreadLocal
         objects that are instances of classes loaded by this class loader.



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


Mime
View raw message