commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1621664 - in /commons/proper/pool/trunk/src: changes/changes.xml main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
Date Mon, 01 Sep 2014 02:51:22 GMT
Author: psteitz
Date: Mon Sep  1 02:51:22 2014
New Revision: 1621664

URL: http://svn.apache.org/r1621664
Log:
Fixed error in GenericKeyedObjectPool constructor causing
minEvictableIdleTimeMillis to be used in place of
timeBetweenEvictionRunsMillis in eviction timer setup when a 
GenericKeyedObjectPoolConfig instance is supplied
to the constructor.

JIRA: POOL-270
Reported by Michael Berman

Modified:
    commons/proper/pool/trunk/src/changes/changes.xml
    commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
    commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.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=1621664&r1=1621663&r2=1621664&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/changes/changes.xml (original)
+++ commons/proper/pool/trunk/src/changes/changes.xml Mon Sep  1 02:51:22 2014
@@ -45,6 +45,11 @@ The <action> type attribute can be add,u
   <body>
   <release version="2.3" date="TBD" description=
 "TBD">
+    <action dev="psteitz" type="fix" issue="POOL-270" due-to="Michael Berman">
+      Fixed error in GenericKeyedObjectPool constructor causing minEvictableIdleTimeMillis
+      to be used in place of timeBetweenEvictionRunsMillis in eviction timer setup
+      when a GenericKeyedObjectPoolConfig instance is supplied to the constructor.
+    </action>
     <action dev="markt" type="fix" issue="POOL-263">
       Fix a threading issue that meant that concurrent calls to close() and
       returnObject() could result in some returned objects not being destroyed.

Modified: commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java?rev=1621664&r1=1621663&r2=1621664&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/main/java/org/apache/commons/pool2/impl/GenericKeyedObjectPool.java
Mon Sep  1 02:51:22 2014
@@ -110,7 +110,7 @@ public class GenericKeyedObjectPool<K,T>
 
         setConfig(config);
 
-        startEvictor(getMinEvictableIdleTimeMillis());
+        startEvictor(getTimeBetweenEvictionRunsMillis());
     }
 
     /**

Modified: commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java?rev=1621664&r1=1621663&r2=1621664&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/trunk/src/test/java/org/apache/commons/pool2/impl/TestGenericKeyedObjectPool.java
Mon Sep  1 02:51:22 2014
@@ -413,6 +413,28 @@ public class TestGenericKeyedObjectPool 
             assertFalse(pool.getBlockWhenExhausted());
         }
     }
+    
+    /** 
+     * JIRA: POOL-270 - make sure constructor correctly sets run
+     * frequency of evictor timer.
+     */
+    @Test
+    public void testContructorEvictionConfig() throws Exception {
+        GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
+        config.setTimeBetweenEvictionRunsMillis(500);
+        config.setMinEvictableIdleTimeMillis(50);
+        config.setNumTestsPerEvictionRun(5);
+        GenericKeyedObjectPool p = new GenericKeyedObjectPool<String, String>(factory,
config);
+        for(int i=0;i<5;i++) {
+            p.addObject("one");
+        }
+        try { Thread.sleep(100); } catch(InterruptedException e) { }
+        assertEquals(5, p.getNumIdle("one"));
+        try { Thread.sleep(500); } catch(InterruptedException e) { }
+        assertEquals(0, p.getNumIdle("one"));
+        p.close();
+    }
+    
 
     @Test(timeout=60000)
     public void testEviction() throws Exception {



Mime
View raw message