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 2012/04/12 22:05:07 UTC

svn commit: r1325480 - in /commons/proper/pool/branches/1_5_RELEASE: ./ src/changes/changes.xml src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java src/java/org/apache/commons/pool/impl/GenericObjectPool.java

Author: markt
Date: Thu Apr 12 20:05:07 2012
New Revision: 1325480

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

Modified:
    commons/proper/pool/branches/1_5_RELEASE/   (props changed)
    commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml
    commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
    commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java

Propchange: commons/proper/pool/branches/1_5_RELEASE/
------------------------------------------------------------------------------
  Merged /commons/proper/pool/branches/POOL_1_X:r1325476

Modified: commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml?rev=1325480&r1=1325479&r2=1325480&view=diff
==============================================================================
--- commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml (original)
+++ commons/proper/pool/branches/1_5_RELEASE/src/changes/changes.xml Thu Apr 12 20:05:07 2012
@@ -25,6 +25,11 @@
       Ensure the evictor thread runs with the same class loader that was in use
       when the pool was created to ensure that the factory class is visible.
     </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.5.7" date="2011-12-20" description="This is a patch release, including bugfixes only.">
     <action dev="psteitz" type="fix" issue="POOL-189" due-to="Bill Speirs">

Modified: commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java?rev=1325480&r1=1325479&r2=1325480&view=diff
==============================================================================
--- commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java (original)
+++ commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericKeyedObjectPool.java Thu Apr 12 20:05:07 2012
@@ -812,6 +812,10 @@ public class GenericKeyedObjectPool exte
      * <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
@@ -827,12 +831,21 @@ public class GenericKeyedObjectPool exte
      * <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;
+        }
     }
 
     /**
@@ -2064,7 +2077,7 @@ public class GenericKeyedObjectPool exte
      */
     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/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java?rev=1325480&r1=1325479&r2=1325480&view=diff
==============================================================================
--- commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java (original)
+++ commons/proper/pool/branches/1_5_RELEASE/src/java/org/apache/commons/pool/impl/GenericObjectPool.java Thu Apr 12 20:05:07 2012
@@ -748,6 +748,9 @@ public class GenericObjectPool extends B
      * <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
@@ -764,12 +767,19 @@ public class GenericObjectPool extends B
      * 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;
+        }
     }
 
     /**