Author: markt
Date: Wed Dec 14 19:34:09 2011
New Revision: 1214417

URL: http://svn.apache.org/viewvc?rev=1214417&view=rev
Log:
Fix POOL-200 for GKOP. Use accessors.

Modified:
    
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java

Modified: 
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
URL: 
http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java?rev=1214417&r1=1214416&r2=1214417&view=diff
==============================================================================
--- 
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
 (original)
+++ 
commons/proper/pool/trunk/src/java/org/apache/commons/pool2/impl/GenericObjectPool.java
 Wed Dec 14 19:34:09 2011
@@ -189,24 +189,9 @@ public class GenericObjectPool<T> extend
     public GenericObjectPool(PoolableObjectFactory<T> factory,
             GenericObjectPoolConfig<T> config) {
         this.factory = factory;
-        this.lifo = config.getLifo();
-        this.maxTotal = config.getMaxTotal();
-        this.maxIdle = config.getMaxIdle();
-        this.maxWait = config.getMaxWait();
-        this.minEvictableIdleTimeMillis =
-                config.getMinEvictableIdleTimeMillis();
-        this.minIdle = config.getMinIdle();
-        this.numTestsPerEvictionRun = config.getNumTestsPerEvictionRun();
-        this.softMinEvictableIdleTimeMillis =
-                config.getSoftMinEvictableIdleTimeMillis();
-        this.testOnBorrow = config.getTestOnBorrow();
-        this.testOnReturn = config.getTestOnReturn();
-        this.testWhileIdle = config.getTestWhileIdle();
-        this.timeBetweenEvictionRunsMillis =
-                config.getTimeBetweenEvictionRunsMillis();
-        this.blockWhenExhausted = config.getBlockWhenExhausted();
+        setConfig(config);
 
-        startEvictor(timeBetweenEvictionRunsMillis);
+        startEvictor(getTimeBetweenEvictionRunsMillis());
 
         initStats();
 
@@ -644,6 +629,7 @@ public class GenericObjectPool<T> extend
      * @see GenericObjectPoolConfig
      */
     public void setConfig(GenericObjectPoolConfig<T> conf) {
+        setLifo(conf.getLifo());
         setMaxIdle(conf.getMaxIdle());
         setMinIdle(conf.getMinIdle());
         setMaxTotal(conf.getMaxTotal());
@@ -658,7 +644,6 @@ public class GenericObjectPool<T> extend
                 conf.getTimeBetweenEvictionRunsMillis());
         setSoftMinEvictableIdleTimeMillis(
                 conf.getSoftMinEvictableIdleTimeMillis());
-        setLifo(conf.getLifo());
     }
 
     /**
@@ -718,7 +703,7 @@ public class GenericObjectPool<T> extend
      */
     @Override
     public T borrowObject() throws Exception {
-        return borrowObject(maxWait);
+        return borrowObject(getMaxWait());
     }
     
     /**
@@ -738,7 +723,7 @@ public class GenericObjectPool<T> extend
 
         // Get local copy of current config so it is consistent for entire
         // method execution
-        boolean blockWhenExhausted = this.blockWhenExhausted;
+        boolean blockWhenExhausted = getBlockWhenExhausted();
 
         boolean create;
         long waitTime = 0;
@@ -1276,6 +1261,7 @@ public class GenericObjectPool<T> extend
      * @return the number of tests for the Evictor to run
      */
     private int getNumTests() {
+        int numTestsPerEvictionRun = getNumTestsPerEvictionRun();
         if (numTestsPerEvictionRun >= 0) {
             return Math.min(numTestsPerEvictionRun, idleObjects.size());
         } else {


Reply via email to