You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2014/09/24 12:35:22 UTC

svn commit: r1627272 - in /tomcat/trunk: java/org/apache/tomcat/dbcp/pool2/ java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java webapps/docs/changelog.xml

Author: markt
Date: Wed Sep 24 10:35:21 2014
New Revision: 1627272

URL: http://svn.apache.org/r1627272
Log:
Pick up improved memory leak fix from Pool 2.

Modified:
    tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/   (props changed)
    tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
    tomcat/trunk/webapps/docs/changelog.xml

Propchange: tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/
------------------------------------------------------------------------------
  Merged /commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2:r1627023-1627271

Modified: tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java?rev=1627272&r1=1627271&r2=1627272&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/dbcp/pool2/impl/BaseGenericObjectPool.java Wed Sep 24 10:35:21 2014
@@ -91,8 +91,8 @@ public abstract class BaseGenericObjectP
     private Evictor evictor = null; // @GuardedBy("evictionLock")
     Iterator<PooledObject<T>> evictionIterator = null; // @GuardedBy("evictionLock")
     /*
-     * Class loader for evictor thread to use since in a J2EE or similar
-     * environment the context class loader for the evictor thread may have
+     * Class loader for evictor thread to use since, in a JavaEE or similar
+     * environment, the context class loader for the evictor thread may not have
      * visibility of the correct factory. See POOL-161. Uses a weak reference to
      * avoid potential memory leaks if the Pool is discarded rather than closed.
      */
@@ -136,9 +136,14 @@ public abstract class BaseGenericObjectP
         // Populate the creation stack trace
         this.creationStackTrace = getStackTrace(new Exception());
 
-        // save the current CCL to be used later by the evictor Thread
-        factoryClassLoader =
-                new WeakReference<>(Thread.currentThread().getContextClassLoader());
+        // save the current TCCL (if any) to be used later by the evictor Thread
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        if (cl == null) {
+            factoryClassLoader = null;
+        } else {
+            factoryClassLoader = new WeakReference<>(cl);
+        }
+
         fairness = config.getFairness();
     }
 
@@ -998,15 +1003,18 @@ public abstract class BaseGenericObjectP
             ClassLoader savedClassLoader =
                     Thread.currentThread().getContextClassLoader();
             try {
-                // Set the class loader for the factory
-                ClassLoader cl = factoryClassLoader.get();
-                if (cl == null) {
-                    // The pool has been dereferenced and the class loader GC'd.
-                    // Cancel this timer so the pool can be GC'd as well.
-                    cancel();
-                    return;
+                if (factoryClassLoader != null) {
+                    // Set the class loader for the factory
+                    ClassLoader cl = factoryClassLoader.get();
+                    if (cl == null) {
+                        // The pool has been dereferenced and the class loader
+                        // GC'd. Cancel this timer so the pool can be GC'd as
+                        // well.
+                        cancel();
+                        return;
+                    }
+                    Thread.currentThread().setContextClassLoader(cl);
                 }
-                Thread.currentThread().setContextClassLoader(cl);
 
                 // Evict from the pool
                 try {

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1627272&r1=1627271&r2=1627272&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Sep 24 10:35:21 2014
@@ -252,7 +252,7 @@
       </fix>
       <fix>
         Update the package renamed copy of Apache Commons Pool 2 to revision
-        1627022 to pick up the fixes since the 2.2 release including some memory
+        1627271 to pick up the fixes since the 2.2 release including some memory
         leak fixes and support for application provided eviction policies.
         (markt)
       </fix>



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