commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Fwd: svn commit: r1767714 - in /commons/proper/pool/trunk/src: changes/changes.xml main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
Date Wed, 02 Nov 2016 18:12:52 GMT
Is it time to push out 2.4.3? There are couple of interesting fixes.

Gary
---------- Forwarded message ----------
From: <markt@apache.org>
Date: Wed, Nov 2, 2016 at 8:53 AM
Subject: svn commit: r1767714 - in /commons/proper/pool/trunk/src:
changes/changes.xml
main/java/org/apache/commons/pool2/impl/BaseGenericObjectPool.java
test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
To: commits@commons.apache.org


Author: markt
Date: Wed Nov  2 15:53:08 2016
New Revision: 1767714

URL: http://svn.apache.org/viewvc?rev=1767714&view=rev
Log:
Check class used for evictionPolicyClassName implements EvictionPolicy

Modified:
    commons/proper/pool/trunk/src/changes/changes.xml
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/
BaseGenericObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/
TestGenericObjectPool.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=1767714&r1=1767713&r2=1767714&view=diff
============================================================
==================
--- commons/proper/pool/trunk/src/changes/changes.xml (original)
+++ commons/proper/pool/trunk/src/changes/changes.xml Wed Nov  2 15:53:08
2016
@@ -67,6 +67,10 @@ The <action> type attribute can be add,u
       maxTotal threads try to borrow objects with different keys at the
same
       time and the factory destroys objects on return.
     </action>
+    <action dev="markt" type="fix">
+      Ensure that any class name used for evictionPolicyClassName
represents a
+      class that implements EvictionPolicy.
+    </action>
   </release>
   <release version="2.4.2" date="2015-08-01" description=
  "This is a patch release, including bug fixes only.">

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=1767714&r1=1767713&r2=1767714&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
Wed Nov  2 15:53:08 2016
@@ -613,6 +613,9 @@ public abstract class BaseGenericObjectP
                 final
                 EvictionPolicy<T> evicPolicy = (EvictionPolicy<T>) policy;
                 this.evictionPolicy = evicPolicy;
+            } else {
+                throw new IllegalArgumentException("[" +
evictionPolicyClassName +
+                        "] does not implement EvictionPolicy");
             }
         } catch (final ClassNotFoundException e) {
             throw new IllegalArgumentException(

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/
pool2/impl/TestGenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/
test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java?
rev=1767714&r1=1767713&r2=1767714&view=diff
============================================================
==================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericObjectPool.java
Wed Nov  2 15:53:08 2016
@@ -1080,6 +1080,14 @@ public class TestGenericObjectPool exten
             // expected
         }

+        try {
+            pool.setEvictionPolicyClassName(java.lang.String.class.
getName());
+            fail("setEvictionPolicyClassName must throw an error if a
class that does not "
+                    + "implement EvictionPolicy is specified.");
+        } catch (final IllegalArgumentException e) {
+            // expected
+        }
+
         pool.setEvictionPolicyClassName(TestEvictionPolicy.class.
getName());
         assertEquals(TestEvictionPolicy.class.getName(), pool.
getEvictionPolicyClassName());

@@ -1704,49 +1712,49 @@ public class TestGenericObjectPool exten
         public SimpleFactory() {
             this(true);
         }
-
+
         public SimpleFactory(final boolean valid) {
             this(valid,valid);
         }
-
+
         public SimpleFactory(final boolean evalid, final boolean ovalid) {
             evenValid = evalid;
             oddValid = ovalid;
         }
-
+
         public synchronized void setValid(final boolean valid) {
             setEvenValid(valid);
             setOddValid(valid);
         }
-
+
         public synchronized void setEvenValid(final boolean valid) {
             evenValid = valid;
         }
-
+
         public synchronized void setOddValid(final boolean valid) {
             oddValid = valid;
         }
-
+
         public synchronized void setThrowExceptionOnPassivate(final
boolean bool) {
             exceptionOnPassivate = bool;
         }
-
+
         public synchronized void setMaxTotal(final int maxTotal) {
             this.maxTotal = maxTotal;
         }
-
+
         public synchronized void setDestroyLatency(final long
destroyLatency) {
             this.destroyLatency = destroyLatency;
         }
-
+
         public synchronized void setMakeLatency(final long makeLatency) {
             this.makeLatency = makeLatency;
         }
-
+
         public synchronized void setValidateLatency(final long
validateLatency) {
             this.validateLatency = validateLatency;
         }
-
+
         @Override
         public PooledObject<String> makeObject() {
             final long waitLatency;
@@ -1767,7 +1775,7 @@ public class TestGenericObjectPool exten
             }
             return new DefaultPooledObject<String>(
String.valueOf(counter));
         }
-
+
         @Override
         public void destroyObject(final PooledObject<String> obj) throws
Exception {
             final long waitLatency;
@@ -1786,7 +1794,7 @@ public class TestGenericObjectPool exten
                 throw new Exception();
             }
         }
-
+
         @Override
         public boolean validateObject(final PooledObject<String> obj) {
             final boolean validate;
@@ -1809,7 +1817,7 @@ public class TestGenericObjectPool exten
             }
             return true;
         }
-
+
         @Override
         public void activateObject(final PooledObject<String> obj) throws
Exception {
             final boolean hurl;
@@ -1828,7 +1836,7 @@ public class TestGenericObjectPool exten
                 }
             }
         }
-
+
         @Override
         public void passivateObject(final PooledObject<String> obj) throws
Exception {
             final boolean hurl;





-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message