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 2014/02/17 14:22:34 UTC

svn commit: r1568981 - in /commons/proper/dbcp/trunk/src: changes/ main/java/org/apache/commons/dbcp2/ main/java/org/apache/commons/dbcp2/datasources/ site/xdoc/ test/java/org/apache/commons/dbcp2/datasources/

Author: markt
Date: Mon Feb 17 13:22:33 2014
New Revision: 1568981

URL: http://svn.apache.org/r1568981
Log:
Fix DBCP-357. Use Connection.isValid() to validate connections unless a validation query has been defined.

Modified:
    commons/proper/dbcp/trunk/src/changes/changes.xml
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
    commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java

Modified: commons/proper/dbcp/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/changes/changes.xml?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/changes/changes.xml (original)
+++ commons/proper/dbcp/trunk/src/changes/changes.xml Mon Feb 17 13:22:33 2014
@@ -172,6 +172,13 @@ The <action> type attribute can be add,u
         Connection.isValid() should not throw an SQLException if the connection
         is closed.
       </action>
+      <action dev="markt" issue="DBCP-357" type="fix">
+        Use Connection.isValid() to validate connections unless a validation
+        query is explicitly configured. Note that this means it is no longer
+        necessary for a validation query to be specified in order for validation
+        to take place. When testing with Oracle, this resulted in database
+        validation being approximately 7 times faster.
+      </action>
     </release>
     <release version="1.5.1" date="TBD" description="TBD">
       <action dev="markt" issue="DBCP-400" type="fix">

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java Mon Feb 17 13:22:33 2014
@@ -696,8 +696,7 @@ public class BasicDataSource
     /**
      * Sets the {@link #testOnBorrow} property. This property determines
      * whether or not the pool will validate objects before they are borrowed
-     * from the pool. For a <code>true</code> value to have any effect, the
-     * <code>validationQuery</code> property must be set to a non-null string.
+     * from the pool.
      *
      * @param testOnBorrow new value for testOnBorrow property
      */
@@ -728,8 +727,7 @@ public class BasicDataSource
     /**
      * Sets the <code>testOnReturn</code> property. This property determines
      * whether or not the pool will validate objects before they are returned
-     * to the pool. For a <code>true</code> value to have any effect, the
-     * <code>validationQuery</code> property must be set to a non-null string.
+     * to the pool.
      *
      * @param testOnReturn new value for testOnReturn property
      */
@@ -940,9 +938,7 @@ public class BasicDataSource
 
     /**
      * Sets the <code>testWhileIdle</code> property. This property determines
-     * whether or not the idle object evictor will validate connections.  For a
-     * <code>true</code> value to have any effect, the
-     * <code>validationQuery</code> property must be set to a non-null string.
+     * whether or not the idle object evictor will validate connections.
      *
      * @param testWhileIdle new value for testWhileIdle property
      */
@@ -1080,7 +1076,8 @@ public class BasicDataSource
      * The SQL query that will be used to validate connections from this pool
      * before returning them to the caller.  If specified, this query
      * <strong>MUST</strong> be an SQL SELECT statement that returns at least
-     * one row.
+     * one row. If not specified, {@link Connection#isValid(int)} will be used
+     * to validate connections.
      */
     private volatile String validationQuery = null;
 
@@ -2016,13 +2013,6 @@ public class BasicDataSource
             }
         }
 
-        // Can't test without a validationQuery
-        if (validationQuery == null) {
-            setTestOnBorrow(false);
-            setTestOnReturn(false);
-            setTestWhileIdle(false);
-        }
-
         // Set up the driver connection factory we will use
         String user = username;
         if (user != null) {

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java Mon Feb 17 13:22:33 2014
@@ -211,7 +211,13 @@ public class PoolableConnection extends 
 
 
     public void validate(String sql, int timeout) throws SQLException {
-        if (sql == null) {
+        if (sql == null || sql.length() == 0) {
+            if (timeout < 0) {
+                timeout = 0;
+            }
+            if (!isValid(timeout)) {
+                throw new SQLException("isValid() returned false");
+            }
             return;
         }
 

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java Mon Feb 17 13:22:33 2014
@@ -64,8 +64,9 @@ public class PoolableConnectionFactory
 
     /**
      * Sets the query I use to {@link #validateObject validate} {@link Connection}s.
-     * Should return at least one row.
-     * Using <tt>null</tt> turns off validation.
+     * Should return at least one row. If not specified,
+     * {@link Connection#isValid(int)} will be used to validate connections.
+     *
      * @param validationQuery a query to use to {@link #validateObject validate} {@link Connection}s.
      */
     public void setValidationQuery(String validationQuery) {

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java Mon Feb 17 13:22:33 2014
@@ -53,6 +53,7 @@ class CPDSConnectionFactory
 
     private final ConnectionPoolDataSource _cpds;
     private final String _validationQuery;
+    private final int _validationQueryTimeout;
     private final boolean _rollbackAfterValidation;
     private ObjectPool<PooledConnectionAndInfo> _pool;
     private final String _username;
@@ -80,7 +81,9 @@ class CPDSConnectionFactory
      * PooledConnection's
      * @param validationQuery a query to use to {@link #validateObject
      * validate} {@link Connection}s. Should return at least one row.
-     * May be <tt>null</tt>
+     * May be <tt>null</tt> in which case {@link Connection#isValid(int)} will
+     * be used to validate connections.
+     * @param validationQueryTimeout Timeout in seconds before validation fails
      * @param rollbackAfterValidation whether a rollback should be issued
      * after {@link #validateObject validating} {@link Connection}s.
      * @param username
@@ -88,11 +91,13 @@ class CPDSConnectionFactory
      */
     public CPDSConnectionFactory(ConnectionPoolDataSource cpds,
                                  String validationQuery,
+                                 int validationQueryTimeout,
                                  boolean rollbackAfterValidation,
                                  String username,
                                  String password) {
         _cpds = cpds;
         _validationQuery = validationQuery;
+        _validationQueryTimeout = validationQueryTimeout;
         _username = username;
         _password = password;
         _rollbackAfterValidation = rollbackAfterValidation;
@@ -166,8 +171,17 @@ class CPDSConnectionFactory
         }
         boolean valid = false;
         PooledConnection pconn = p.getObject().getPooledConnection();
-        String query = _validationQuery;
-        if (null != query) {
+        if (null == _validationQuery) {
+            int timeout = _validationQueryTimeout;
+            if (timeout < 0) {
+                timeout = 0;
+            }
+            try {
+                valid = pconn.getConnection().isValid(timeout);
+            } catch (SQLException e) {
+                valid = false;
+            }
+        } else {
             Connection conn = null;
             Statement stmt = null;
             ResultSet rset = null;
@@ -179,7 +193,7 @@ class CPDSConnectionFactory
             try {
                 conn = pconn.getConnection();
                 stmt = conn.createStatement();
-                rset = stmt.executeQuery(query);
+                rset = stmt.executeQuery(_validationQuery);
                 if (rset.next()) {
                     valid = true;
                 } else {
@@ -196,8 +210,6 @@ class CPDSConnectionFactory
                 Utils.closeQuietly(conn);
                 validatingSet.remove(pconn);
             }
-        } else {
-            valid = true;
         }
         return valid;
     }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSource.java Mon Feb 17 13:22:33 2014
@@ -156,6 +156,7 @@ public abstract class InstanceKeyDataSou
 
     // Connection factory properties
     private String validationQuery = null;
+    private int validationQueryTimeout = -1;
     private boolean rollbackAfterValidation = false;
     private long maxConnLifetimeMillis = -1;
 
@@ -772,7 +773,8 @@ public abstract class InstanceKeyDataSou
      * The SQL query that will be used to validate connections from this pool
      * before returning them to the caller.  If specified, this query
      * <strong>MUST</strong> be an SQL SELECT statement that returns at least
-     * one row.
+     * one row. If not specified, {@link Connection#isValid(int)} will be used
+     * to validate connections.
      */
     public String getValidationQuery() {
         return this.validationQuery;
@@ -782,8 +784,8 @@ public abstract class InstanceKeyDataSou
      * The SQL query that will be used to validate connections from this pool
      * before returning them to the caller.  If specified, this query
      * <strong>MUST</strong> be an SQL SELECT statement that returns at least
-     * one row. If none of the properties, testOnBorow, testOnReturn, testWhileIdle
-     * have been previously set, calling this method sets testOnBorrow to true.
+     * one row. If not specified, connections will be validated using
+     * {@link Connection#isValid(int)}.
      */
     public void setValidationQuery(String validationQuery) {
         assertInitializationAllowed();
@@ -791,6 +793,22 @@ public abstract class InstanceKeyDataSou
     }
 
     /**
+     * Returns the timeout in seconds before the validation query fails.
+     */
+    public int getValidationQueryTimeout() {
+        return validationQueryTimeout;
+    }
+
+    /**
+     * Sets the timeout in seconds before the validation query fails.
+     *
+     * @param validationQueryTimeout    The new timeout in seconds
+     */
+    public void setValidationQueryTimeout(int validationQueryTimeout) {
+        this.validationQueryTimeout = validationQueryTimeout;
+    }
+
+    /**
      * Whether a rollback will be issued after executing the SQL query
      * that will be used to validate connections from this pool
      * before returning them to the caller.

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java Mon Feb 17 13:22:33 2014
@@ -249,6 +249,12 @@ abstract class InstanceKeyDataSourceFact
             ikds.setValidationQuery(ra.getContent().toString());
         }
 
+        ra = ref.get("validationQueryTimeout");
+        if (ra != null && ra.getContent() != null) {
+            ikds.setValidationQueryTimeout(Integer.valueOf(
+                    ra.getContent().toString()).intValue());
+        }
+
         ra = ref.get("rollbackAfterValidation");
         if (ra != null && ra.getContent() != null) {
             ikds.setRollbackAfterValidation(Boolean.valueOf(

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java Mon Feb 17 13:22:33 2014
@@ -54,6 +54,7 @@ class KeyedCPDSConnectionFactory
 
     private final ConnectionPoolDataSource _cpds;
     private final String _validationQuery;
+    private final int _validationQueryTimeout;
     private final boolean _rollbackAfterValidation;
     private KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> _pool;
     private long maxConnLifetimeMillis = -1;
@@ -71,31 +72,25 @@ class KeyedCPDSConnectionFactory
     private final Map<PooledConnection, PooledConnectionAndInfo> pcMap =
         new ConcurrentHashMap<>();
 
-    /**
-     * Create a new <tt>KeyedPoolableConnectionFactory</tt>.
-     * @param cpds the ConnectionPoolDataSource from which to obtain PooledConnection's
-     * @param validationQuery a query to use to {*link #validateObject validate} {*link Connection}s.
-     * Should return at least one row. May be <tt>null</tt>
-     */
-    public KeyedCPDSConnectionFactory(ConnectionPoolDataSource cpds,
-                                      String validationQuery) {
-        this(cpds , validationQuery, false);
-    }
 
     /**
      * Create a new <tt>KeyedPoolableConnectionFactory</tt>.
      * @param cpds the ConnectionPoolDataSource from which to obtain
      * PooledConnections
      * @param validationQuery a query to use to {@link #validateObject validate}
-     * {@link Connection}s.  Should return at least one row. May be <tt>null</tt>
+     * {@link Connection}s.  Should return at least one row. May be
+     * <tt>null</tt> in which case3 {@link Connection#isValid(int)} will be used
+     * to validate connections.
      * @param rollbackAfterValidation whether a rollback should be issued after
      * {@link #validateObject validating} {@link Connection}s.
      */
     public KeyedCPDSConnectionFactory(ConnectionPoolDataSource cpds,
                                       String validationQuery,
+                                      int validationQueryTimeout,
                                       boolean rollbackAfterValidation) {
         _cpds = cpds;
         _validationQuery = validationQuery;
+        _validationQueryTimeout = validationQueryTimeout;
         _rollbackAfterValidation = rollbackAfterValidation;
     }
 
@@ -176,8 +171,17 @@ class KeyedCPDSConnectionFactory
         }
         boolean valid = false;
         PooledConnection pconn = p.getObject().getPooledConnection();
-        String query = _validationQuery;
-        if (null != query) {
+        if (null == _validationQuery) {
+            int timeout = _validationQueryTimeout;
+            if (timeout < 0) {
+                timeout = 0;
+            }
+            try {
+                valid = pconn.getConnection().isValid(timeout);
+            } catch (SQLException e) {
+                valid = false;
+            }
+        } else {
             Connection conn = null;
             Statement stmt = null;
             ResultSet rset = null;
@@ -189,7 +193,7 @@ class KeyedCPDSConnectionFactory
             try {
                 conn = pconn.getConnection();
                 stmt = conn.createStatement();
-                rset = stmt.executeQuery(query);
+                rset = stmt.executeQuery(_validationQuery);
                 if (rset.next()) {
                     valid = true;
                 } else {
@@ -206,8 +210,6 @@ class KeyedCPDSConnectionFactory
                 Utils.closeQuietly(conn);
                 validatingSet.remove(pconn);
             }
-        } else {
-            valid = true;
         }
         return valid;
     }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java Mon Feb 17 13:22:33 2014
@@ -977,8 +977,8 @@ public class PerUserPoolDataSource exten
         // the factory with the pool, so we do not have to do so
         // explicitly)
         CPDSConnectionFactory factory = new CPDSConnectionFactory(cpds,
-                getValidationQuery(), isRollbackAfterValidation(), username,
-                password);
+                getValidationQuery(), getValidationQueryTimeout(),
+                isRollbackAfterValidation(), username, password);
         factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis());
 
         // Create an object pool to contain our PooledConnections

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSource.java Mon Feb 17 13:22:33 2014
@@ -172,7 +172,7 @@ public class SharedPoolDataSource extend
 
         // Create an object pool to contain our PooledConnections
         factory = new KeyedCPDSConnectionFactory(cpds, getValidationQuery(),
-                isRollbackAfterValidation());
+                getValidationQueryTimeout(), isRollbackAfterValidation());
         factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis());
 
         GenericKeyedObjectPoolConfig config =

Modified: commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml (original)
+++ commons/proper/dbcp/trunk/src/site/xdoc/configuration.xml Mon Feb 17 13:22:33 2014
@@ -193,7 +193,8 @@ loaded system will vary but the default 
 The SQL query that will be used to validate connections from this pool
 before returning them to the caller.  If specified, this query
 <strong>MUST</strong> be an SQL SELECT statement that returns at least
-one row.
+one row. If not specified, connections will be validation by calling the
+isValid() method.
    </td>
 </tr>
 <tr>
@@ -202,10 +203,7 @@ one row.
    <td>
       The indication of whether objects will be validated before being
       borrowed from the pool.  If the object fails to validate, it will be
-      dropped from the pool, and we will attempt to borrow another.<br/>
-      <strong>NOTE</strong> - for a <code>true</code> value to have any effect,
-      the <code>validationQuery</code> parameter must be set to a non-null
-      string.
+      dropped from the pool, and we will attempt to borrow another.
    </td>
 </tr>
 <tr>
@@ -213,9 +211,7 @@ one row.
    <td>false</td>
    <td>
       The indication of whether objects will be validated before being
-      returned to the pool. <br/> <strong>NOTE</strong> - for a 
-      <code>true</code> value to have any effect, the 
-      <code>validationQuery</code> parameter must be set to a non-null string.
+      returned to the pool.
    </td>
 </tr>
 <tr>
@@ -224,9 +220,7 @@ one row.
    <td>
       The indication of whether objects will be validated by the idle object
       evictor (if any).  If an object fails to validate, it will be dropped
-      from the pool. <br/> <strong>NOTE</strong> - for a <code>true</code>
-      value to have any effect, the <code>validationQuery</code> parameter
-      must be set to a non-null string.
+      from the pool.
    </td>
 </tr>
 <tr>

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java Mon Feb 17 13:22:33 2014
@@ -88,8 +88,8 @@ public class TestCPDSConnectionFactory e
      */
     public void testConnectionErrorCleanup() throws Exception {
         // Setup factory
-        CPDSConnectionFactory factory =
-                new CPDSConnectionFactory(cpds, null, false, "username", "password");
+        CPDSConnectionFactory factory = new CPDSConnectionFactory(
+                cpds, null, -1, false, "username", "password");
         GenericObjectPool<PooledConnectionAndInfo> pool =
                 new GenericObjectPool<>(factory);
         factory.setPool(pool);

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java?rev=1568981&r1=1568980&r2=1568981&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestKeyedCPDSConnectionFactory.java Mon Feb 17 13:22:33 2014
@@ -91,7 +91,7 @@ public class TestKeyedCPDSConnectionFact
         // Setup factory
         UserPassKey key = new UserPassKey("username", "password");
         KeyedCPDSConnectionFactory factory =
-            new KeyedCPDSConnectionFactory(cpds, null, false);
+            new KeyedCPDSConnectionFactory(cpds, null, -1, false);
         KeyedObjectPool<UserPassKey, PooledConnectionAndInfo> pool = new GenericKeyedObjectPool<>(factory);
         factory.setPool(pool);