This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git


The following commit(s) were added to refs/heads/master by this push:
     new 2bf17abd Internal refactoring
2bf17abd is described below

commit 2bf17abdb5b2e2752cf3420bd6afb7c559409afb
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sun Dec 15 18:18:34 2024 -0500

    Internal refactoring
---
 .../datasources/KeyedCPDSConnectionFactory.java      | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
 
b/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
index c06eda5e..bd8b89fd 100644
--- 
a/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
+++ 
b/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
@@ -19,8 +19,6 @@ package org.apache.commons.dbcp2.datasources;
 import java.sql.Connection;
 import java.sql.SQLException;
 import java.time.Duration;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 
 import javax.sql.ConnectionEvent;
 import javax.sql.ConnectionEventListener;
@@ -46,11 +44,6 @@ final class KeyedCPDSConnectionFactory extends 
AbstractConnectionFactory
 
     private KeyedObjectPool<UserPassKey, PooledConnectionAndInfo> pool;
 
-    /**
-     * Map of PooledConnectionAndInfo instances
-     */
-    private final Map<PooledConnection, PooledConnectionAndInfo> pcMap = new 
ConcurrentHashMap<>();
-
     /**
      * Creates a new {@code KeyedPoolableConnectionFactory}.
      *
@@ -72,7 +65,7 @@ final class KeyedCPDSConnectionFactory extends 
AbstractConnectionFactory
     }
 
     @Override
-    public void activateObject(final UserPassKey key, final 
PooledObject<PooledConnectionAndInfo> pooledObject) throws SQLException {
+    public void activateObject(final UserPassKey ignored, final 
PooledObject<PooledConnectionAndInfo> pooledObject) throws SQLException {
         validateLifetime(pooledObject);
     }
 
@@ -147,7 +140,7 @@ final class KeyedCPDSConnectionFactory extends 
AbstractConnectionFactory
      * Closes the PooledConnection and stops listening for events from it.
      */
     @Override
-    public void destroyObject(final UserPassKey key, final 
PooledObject<PooledConnectionAndInfo> pooledObject) throws SQLException {
+    public void destroyObject(final UserPassKey ignored, final 
PooledObject<PooledConnectionAndInfo> pooledObject) throws SQLException {
         final PooledConnection pooledConnection = 
pooledObject.getObject().getPooledConnection();
         pooledConnection.removeConnectionEventListener(this);
         pcMap.remove(pooledConnection);
@@ -203,22 +196,19 @@ final class KeyedCPDSConnectionFactory extends 
AbstractConnectionFactory
         } else {
             pooledConnection = cpds.getPooledConnection(userName, password);
         }
-
         if (pooledConnection == null) {
             throw new IllegalStateException("Connection pool data source 
returned null from getPooledConnection");
         }
-
         // should we add this object as a listener or the pool.
         // consider the validateObject method in decision
         pooledConnection.addConnectionEventListener(this);
         final PooledConnectionAndInfo pci = new 
PooledConnectionAndInfo(pooledConnection, userPassKey);
         pcMap.put(pooledConnection, pci);
-
         return new DefaultPooledObject<>(pci);
     }
 
     @Override
-    public void passivateObject(final UserPassKey key, final 
PooledObject<PooledConnectionAndInfo> pooledObject) throws SQLException {
+    public void passivateObject(final UserPassKey ignored, final 
PooledObject<PooledConnectionAndInfo> pooledObject) throws SQLException {
         validateLifetime(pooledObject);
     }
 
@@ -240,7 +230,7 @@ final class KeyedCPDSConnectionFactory extends 
AbstractConnectionFactory
      * A query validation timeout greater than 0 and less than 1 second is 
converted to 1 second.
      * </p>
      *
-     * @param key
+     * @param ignored
      *            ignored
      * @param pooledObject
      *            wrapped {@code PooledConnectionAndInfo} containing the 
connection to validate
@@ -248,7 +238,7 @@ final class KeyedCPDSConnectionFactory extends 
AbstractConnectionFactory
      * @throws ArithmeticException if the query validation timeout does not 
fit as seconds in an int.
      */
     @Override
-    public boolean validateObject(final UserPassKey key, final 
PooledObject<PooledConnectionAndInfo> pooledObject) {
+    public boolean validateObject(final UserPassKey ignored, final 
PooledObject<PooledConnectionAndInfo> pooledObject) {
         return super.validateObject(pooledObject);
     }
 }

Reply via email to