commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1627022 - in /commons/proper/pool/trunk/src: changes/changes.xml main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
Date Tue, 23 Sep 2014 13:39:13 GMT
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



Mime
View raw message