You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2014/09/23 15:39:13 UTC

svn commit: r1627022 - in /commons/proper/pool/trunk/src: changes/changes.xml main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java

Author: markt
Date: Tue Sep 23 13:39:13 2014
New Revision: 1627022

URL: http://svn.apache.org/r1627022
Log:
Use the thread context class loader to load custom eviction policies. This allows application provided eviction policies to be used in a container environment when the pooling implementation is provided by the container.

Modified:
    commons/proper/pool/trunk/src/changes/changes.xml
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java

Modified: commons/proper/pool/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/changes/changes.xml?rev=1627022&r1=1627021&r2=1627022&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/changes/changes.xml (original)
+++ commons/proper/pool/trunk/src/changes/changes.xml Tue Sep 23 13:39:13 2014
@@ -92,6 +92,11 @@ The <action> type attribute can be add,u
       Protect against a user provided eviction policy throwing an exception and
       stopping the Evictor thread.
     </action>
+    <action dev="markt" type="fix">
+      Use the thread context class loader to load custom eviction policies. This
+      allows application provided eviction policies to be used in a container
+      environment when the pooling implementation is provided by the container.
+    </action>
   </release>
   <release version="2.2" date="2014-02-24" description=
 "This is a maintenance release that adds a new testOnCreate configuration option

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java?rev=1627022&r1=1627021&r2=1627022&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java (original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java Tue Sep 23 13:39:13 2014
@@ -591,7 +591,8 @@ public abstract class BaseGenericObjectP
     public final void setEvictionPolicyClassName(
             String evictionPolicyClassName) {
         try {
-            Class<?> clazz = Class.forName(evictionPolicyClassName);
+            Class<?> clazz = Class.forName(evictionPolicyClassName, true,
+                    Thread.currentThread().getContextClassLoader());
             Object policy = clazz.newInstance();
             if (policy instanceof EvictionPolicy<?>) {
                 @SuppressWarnings("unchecked") // safe, because we just checked the class