commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1325476 - in /commons/proper/pool/branches/POOL_1_X/src: changes/changes.xml java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java java/org/apache/commons/pool/impl/GenericObjectPool.java
Date Thu, 12 Apr 2012 19:58:39 GMT
Author: markt
Date: Thu Apr 12 19:58:38 2012
New Revision: 1325476

URL: http://svn.apache.org/viewvc?rev=1325476&view=rev
Log:
POOL-212. If minIdle > maxIdle use maxIdle in place of minIdle

Modified:
    commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml
    commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
    commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericObjectPool.java

Modified: commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml?rev=1325476&r1=1325475&r2=1325476&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml (original)
+++ commons/proper/pool/branches/POOL_1_X/src/changes/changes.xml Thu Apr 12 19:58:38 2012
@@ -29,6 +29,11 @@
     <action dev="ggregory" type="fix" issue="POOL-210">
       Jar manifest.mf does not contain SVN information for Implementation-Build.
     </action>
+    <action dev="markt" type="fix" issue="POOL-212">
+      If a pool is configured with maxIdle < minIdle, ensure the evictor does
+      not create minIdle instances only to have them immediately destroyed by
+      using maxIdle for minIdle in this case.
+    </action>
   </release>
   <release version="1.6" date="2012-01-07" description="Adds generics and requires Java
5.">
     <action dev="ggregory" type="add" issue="POOL-208">

Modified: commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=1325476&r1=1325475&r2=1325476&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
(original)
+++ commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
Thu Apr 12 19:58:38 2012
@@ -815,6 +815,10 @@ public class GenericKeyedObjectPool<K, V
      * <code>timeBetweenEvictionRunsMillis > 0</code> and attempts to ensure
      * that each pool has the required minimum number of instances are only
      * made during idle object eviction runs.
+     * <p>
+     * If the configured value of minIdle is greater than the configured value
+     * for maxIdle then the value of maxIdle will be used instead.
+     * 
      * @param poolSize - The minimum size of the each keyed pool
      * @since Pool 1.3
      * @see #getMinIdle
@@ -830,12 +834,21 @@ public class GenericKeyedObjectPool<K, V
      * <code>timeBetweenEvictionRunsMillis > 0</code> and attempts to ensure
      * that each pool has the required minimum number of instances are only
      * made during idle object eviction runs.
+     * <p>
+     * If the configured value of minIdle is greater than the configured value
+     * for maxIdle then the value of maxIdle will be used instead.
+     * 
      * @return minimum size of the each keyed pool
      * @since Pool 1.3
      * @see #setTimeBetweenEvictionRunsMillis
      */
     public int getMinIdle() {
-        return _minIdle;
+        int maxIdle = getMaxIdle();
+        if (_minIdle > maxIdle) {
+            return maxIdle;
+        } else {
+            return _minIdle;
+        }
     }
 
     /**
@@ -2081,7 +2094,7 @@ public class GenericKeyedObjectPool<K, V
     @SuppressWarnings("unchecked")
     private void ensureMinIdle() throws Exception {
         //Check if should sustain the pool
-        if (_minIdle > 0) {
+        if (getMinIdle() > 0) {
             Object[] keysCopy;
             synchronized(this) {
                 // Get the current set of keys

Modified: commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=1325476&r1=1325475&r2=1325476&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
(original)
+++ commons/proper/pool/branches/POOL_1_X/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
Thu Apr 12 19:58:38 2012
@@ -750,6 +750,9 @@ public class GenericObjectPool<T> extend
      * <code>numActive + numIdle >= maxActive.</code>
      * This setting has no effect if the idle object evictor is disabled
      * (i.e. if <code>timeBetweenEvictionRunsMillis <= 0</code>).
+     * <p>
+     * If the configured value of minIdle is greater than the configured value
+     * for maxIdle then the value of maxIdle will be used instead.
      *
      * @param minIdle The minimum number of objects.
      * @see #getMinIdle
@@ -766,12 +769,19 @@ public class GenericObjectPool<T> extend
      * Returns the minimum number of objects allowed in the pool
      * before the evictor thread (if active) spawns new objects.
      * (Note no objects are created when: numActive + numIdle >= maxActive)
+     * <p>
+     * If the configured value of minIdle is greater than the configured value
+     * for maxIdle then the value of maxIdle will be used instead.
      *
      * @return The minimum number of objects.
      * @see #setMinIdle
      */
     public synchronized int getMinIdle() {
-        return _minIdle;
+        if (_minIdle > _maxIdle) {
+            return _maxIdle;
+        } else {
+            return _minIdle;
+        }
     }
 
     /**



Mime
View raw message