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 cd2b1751 Normalize local variable naming
cd2b1751 is described below

commit cd2b17518952be0de44da2eee444abc6cf7c0391
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sat May 3 16:41:10 2025 -0400

    Normalize local variable naming
---
 .../commons/dbcp2/PoolableConnectionFactory.java   | 30 ++++++------
 .../apache/commons/dbcp2/PoolingConnection.java    | 32 ++++++-------
 .../dbcp2/cpdsadapter/PooledConnectionImpl.java    | 54 +++++++++++-----------
 3 files changed, 56 insertions(+), 60 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java 
b/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
index 85930db3..6d1fc8e9 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
@@ -113,29 +113,25 @@ public class PoolableConnectionFactory implements 
PooledObjectFactory<PoolableCo
 
     @Override
     public void activateObject(final PooledObject<PoolableConnection> p) 
throws SQLException {
-
         validateLifetime(p);
-
-        final PoolableConnection pConnection = p.getObject();
-        pConnection.activate();
-
-        if (defaultAutoCommit != null && pConnection.getAutoCommit() != 
defaultAutoCommit) {
-            pConnection.setAutoCommit(defaultAutoCommit);
+        final PoolableConnection poolableConnection = p.getObject();
+        poolableConnection.activate();
+        if (defaultAutoCommit != null && poolableConnection.getAutoCommit() != 
defaultAutoCommit) {
+            poolableConnection.setAutoCommit(defaultAutoCommit);
         }
-        if (defaultTransactionIsolation != UNKNOWN_TRANSACTION_ISOLATION
-                && pConnection.getTransactionIsolation() != 
defaultTransactionIsolation) {
-            pConnection.setTransactionIsolation(defaultTransactionIsolation);
+        if (defaultTransactionIsolation != UNKNOWN_TRANSACTION_ISOLATION && 
poolableConnection.getTransactionIsolation() != defaultTransactionIsolation) {
+            
poolableConnection.setTransactionIsolation(defaultTransactionIsolation);
         }
-        if (defaultReadOnly != null && pConnection.isReadOnly() != 
defaultReadOnly) {
-            pConnection.setReadOnly(defaultReadOnly);
+        if (defaultReadOnly != null && poolableConnection.isReadOnly() != 
defaultReadOnly) {
+            poolableConnection.setReadOnly(defaultReadOnly);
         }
-        if (defaultCatalog != null && 
!defaultCatalog.equals(pConnection.getCatalog())) {
-            pConnection.setCatalog(defaultCatalog);
+        if (defaultCatalog != null && 
!defaultCatalog.equals(poolableConnection.getCatalog())) {
+            poolableConnection.setCatalog(defaultCatalog);
         }
-        if (defaultSchema != null && 
!defaultSchema.equals(Jdbc41Bridge.getSchema(pConnection))) {
-            Jdbc41Bridge.setSchema(pConnection, defaultSchema);
+        if (defaultSchema != null && 
!defaultSchema.equals(Jdbc41Bridge.getSchema(poolableConnection))) {
+            Jdbc41Bridge.setSchema(poolableConnection, defaultSchema);
         }
-        pConnection.setDefaultQueryTimeout(defaultQueryTimeoutDuration);
+        poolableConnection.setDefaultQueryTimeout(defaultQueryTimeoutDuration);
     }
 
     @Override
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java 
b/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
index 6fc99cc2..52936fb1 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
@@ -74,7 +74,7 @@ public class PoolingConnection extends 
DelegatingConnection<Connection>
     }
 
     /** Pool of {@link PreparedStatement}s. and {@link CallableStatement}s */
-    private KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> pStmtPool;
+    private KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> stmtPool;
 
     private boolean clearStatementPoolOnReturn;
 
@@ -109,9 +109,9 @@ public class PoolingConnection extends 
DelegatingConnection<Connection>
     @Override
     public synchronized void close() throws SQLException {
         try {
-            if (null != pStmtPool) {
-                final KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> 
oldPool = pStmtPool;
-                pStmtPool = null;
+            if (null != stmtPool) {
+                final KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> 
oldPool = stmtPool;
+                stmtPool = null;
                 try {
                     oldPool.close();
                 } catch (final RuntimeException e) {
@@ -141,9 +141,9 @@ public class PoolingConnection extends 
DelegatingConnection<Connection>
      * @since 2.8.0
      */
     public void connectionReturnedToPool() throws SQLException {
-        if (pStmtPool != null && clearStatementPoolOnReturn) {
+        if (stmtPool != null && clearStatementPoolOnReturn) {
             try {
-                pStmtPool.clear();
+                stmtPool.clear();
             } catch (final Exception e) {
                 throw new SQLException("Error clearing statement pool", e);
             }
@@ -344,7 +344,7 @@ public class PoolingConnection extends 
DelegatingConnection<Connection>
      * @since 2.8.0
      */
     public KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> 
getStatementPool() {
-        return pStmtPool;
+        return stmtPool;
     }
 
     /**
@@ -365,11 +365,11 @@ public class PoolingConnection extends 
DelegatingConnection<Connection>
         if (key.getStmtType() == StatementType.PREPARED_STATEMENT) {
             final PreparedStatement statement = (PreparedStatement) 
key.createStatement(getDelegate());
             @SuppressWarnings({"rawtypes", "unchecked" }) // Unable to find 
way to avoid this
-            final PoolablePreparedStatement pps = new 
PoolablePreparedStatement(statement, key, pStmtPool, this);
+            final PoolablePreparedStatement pps = new 
PoolablePreparedStatement(statement, key, stmtPool, this);
             return new DefaultPooledObject<>(pps);
         }
         final CallableStatement statement = (CallableStatement) 
key.createStatement(getDelegate());
-        final PoolableCallableStatement pcs = new 
PoolableCallableStatement(statement, key, pStmtPool, this);
+        final PoolableCallableStatement pcs = new 
PoolableCallableStatement(statement, key, stmtPool, this);
         return new DefaultPooledObject<>(pcs);
     }
 
@@ -479,11 +479,11 @@ public class PoolingConnection extends 
DelegatingConnection<Connection>
      *             Wraps an underlying exception.
      */
     private PreparedStatement prepareStatement(final PStmtKey key) throws 
SQLException {
-        if (null == pStmtPool) {
+        if (null == stmtPool) {
             throw new SQLException("Statement pool is null - closed or invalid 
PoolingConnection.");
         }
         try {
-            return pStmtPool.borrowObject(key);
+            return stmtPool.borrowObject(key);
         } catch (final NoSuchElementException e) {
             throw new SQLException("MaxOpenPreparedStatements limit reached", 
e);
         } catch (final RuntimeException e) {
@@ -615,19 +615,19 @@ public class PoolingConnection extends 
DelegatingConnection<Connection>
      *            the prepared statement pool.
      */
     public void setStatementPool(final KeyedObjectPool<PStmtKey, 
DelegatingPreparedStatement> pool) {
-        pStmtPool = pool;
+        stmtPool = pool;
     }
 
     @Override
     public synchronized String toString() {
-        if (pStmtPool instanceof GenericKeyedObjectPool) {
+        if (stmtPool instanceof GenericKeyedObjectPool) {
             // DBCP-596 PoolingConnection.toString() causes StackOverflowError
-            final GenericKeyedObjectPool<?, ?> gkop = 
(GenericKeyedObjectPool<?, ?>) pStmtPool;
+            final GenericKeyedObjectPool<?, ?> gkop = 
(GenericKeyedObjectPool<?, ?>) stmtPool;
             if (gkop.getFactory() == this) {
-                return "PoolingConnection: " + pStmtPool.getClass() + "@" + 
System.identityHashCode(pStmtPool);
+                return "PoolingConnection: " + stmtPool.getClass() + "@" + 
System.identityHashCode(stmtPool);
             }
         }
-        return "PoolingConnection: " + Objects.toString(pStmtPool);
+        return "PoolingConnection: " + Objects.toString(stmtPool);
     }
 
     /**
diff --git 
a/src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java 
b/src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
index 745be7f4..f7a11735 100644
--- 
a/src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
+++ 
b/src/main/java/org/apache/commons/dbcp2/cpdsadapter/PooledConnectionImpl.java
@@ -84,7 +84,7 @@ final class PooledConnectionImpl
     private boolean closed;
 
     /** My pool of {@link PreparedStatement}s. */
-    private KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> pStmtPool;
+    private KeyedObjectPool<PStmtKey, DelegatingPreparedStatement> stmtPool;
 
     /**
      * Controls access to the underlying connection.
@@ -157,11 +157,11 @@ final class PooledConnectionImpl
         assertOpen();
         closed = true;
         try {
-            if (pStmtPool != null) {
+            if (stmtPool != null) {
                 try {
-                    pStmtPool.close();
+                    stmtPool.close();
                 } finally {
-                    pStmtPool = null;
+                    stmtPool = null;
                 }
             }
         } catch (final RuntimeException e) {
@@ -427,13 +427,13 @@ final class PooledConnectionImpl
         if (key.getStmtType() == StatementType.PREPARED_STATEMENT) {
             final PreparedStatement statement = (PreparedStatement) 
key.createStatement(connection);
             @SuppressWarnings({"rawtypes", "unchecked" }) // Unable to find 
way to avoid this
-            final PoolablePreparedStatement pps = new 
PoolablePreparedStatement(statement, key, pStmtPool,
+            final PoolablePreparedStatement pps = new 
PoolablePreparedStatement(statement, key, stmtPool,
                     delegatingConnection);
             return new DefaultPooledObject<>(pps);
         }
         final CallableStatement statement = (CallableStatement) 
key.createStatement(connection);
         @SuppressWarnings("unchecked")
-        final PoolableCallableStatement pcs = new 
PoolableCallableStatement(statement, key, pStmtPool,
+        final PoolableCallableStatement pcs = new 
PoolableCallableStatement(statement, key, stmtPool,
                 (DelegatingConnection<Connection>) delegatingConnection);
         return new DefaultPooledObject<>(pcs);
     }
@@ -477,11 +477,11 @@ final class PooledConnectionImpl
      */
     @SuppressWarnings("resource") // getRawConnection() does not allocate
     CallableStatement prepareCall(final String sql) throws SQLException {
-        if (pStmtPool == null) {
+        if (stmtPool == null) {
             return getRawConnection().prepareCall(sql);
         }
         try {
-            return (CallableStatement) pStmtPool.borrowObject(createKey(sql, 
StatementType.CALLABLE_STATEMENT));
+            return (CallableStatement) stmtPool.borrowObject(createKey(sql, 
StatementType.CALLABLE_STATEMENT));
         } catch (final RuntimeException e) {
             throw e;
         } catch (final Exception e) {
@@ -511,11 +511,11 @@ final class PooledConnectionImpl
     @SuppressWarnings("resource") // getRawConnection() does not allocate
     CallableStatement prepareCall(final String sql, final int resultSetType, 
final int resultSetConcurrency)
             throws SQLException {
-        if (pStmtPool == null) {
+        if (stmtPool == null) {
             return getRawConnection().prepareCall(sql, resultSetType, 
resultSetConcurrency);
         }
         try {
-            return (CallableStatement) pStmtPool.borrowObject(
+            return (CallableStatement) stmtPool.borrowObject(
                     createKey(sql, resultSetType, resultSetConcurrency, 
StatementType.CALLABLE_STATEMENT));
         } catch (final RuntimeException e) {
             throw e;
@@ -549,11 +549,11 @@ final class PooledConnectionImpl
     @SuppressWarnings("resource") // getRawConnection() does not allocate
     CallableStatement prepareCall(final String sql, final int resultSetType, 
final int resultSetConcurrency,
             final int resultSetHoldability) throws SQLException {
-        if (pStmtPool == null) {
+        if (stmtPool == null) {
             return getRawConnection().prepareCall(sql, resultSetType, 
resultSetConcurrency, resultSetHoldability);
         }
         try {
-            return (CallableStatement) pStmtPool.borrowObject(createKey(sql, 
resultSetType, resultSetConcurrency,
+            return (CallableStatement) stmtPool.borrowObject(createKey(sql, 
resultSetType, resultSetConcurrency,
                     resultSetHoldability, StatementType.CALLABLE_STATEMENT));
         } catch (final RuntimeException e) {
             throw e;
@@ -572,11 +572,11 @@ final class PooledConnectionImpl
      */
     @SuppressWarnings("resource") // getRawConnection() does not allocate
     PreparedStatement prepareStatement(final String sql) throws SQLException {
-        if (pStmtPool == null) {
+        if (stmtPool == null) {
             return getRawConnection().prepareStatement(sql);
         }
         try {
-            return pStmtPool.borrowObject(createKey(sql));
+            return stmtPool.borrowObject(createKey(sql));
         } catch (final RuntimeException e) {
             throw e;
         } catch (final Exception e) {
@@ -599,11 +599,11 @@ final class PooledConnectionImpl
      */
     @SuppressWarnings("resource") // getRawConnection() does not allocate
     PreparedStatement prepareStatement(final String sql, final int 
autoGeneratedKeys) throws SQLException {
-        if (pStmtPool == null) {
+        if (stmtPool == null) {
             return getRawConnection().prepareStatement(sql, autoGeneratedKeys);
         }
         try {
-            return pStmtPool.borrowObject(createKey(sql, autoGeneratedKeys));
+            return stmtPool.borrowObject(createKey(sql, autoGeneratedKeys));
         } catch (final RuntimeException e) {
             throw e;
         } catch (final Exception e) {
@@ -632,11 +632,11 @@ final class PooledConnectionImpl
     @SuppressWarnings("resource") // getRawConnection() does not allocate
     PreparedStatement prepareStatement(final String sql, final int 
resultSetType, final int resultSetConcurrency)
             throws SQLException {
-        if (pStmtPool == null) {
+        if (stmtPool == null) {
             return getRawConnection().prepareStatement(sql, resultSetType, 
resultSetConcurrency);
         }
         try {
-            return pStmtPool.borrowObject(createKey(sql, resultSetType, 
resultSetConcurrency));
+            return stmtPool.borrowObject(createKey(sql, resultSetType, 
resultSetConcurrency));
         } catch (final RuntimeException e) {
             throw e;
         } catch (final Exception e) {
@@ -647,11 +647,11 @@ final class PooledConnectionImpl
     @SuppressWarnings("resource") // getRawConnection() does not allocate
     PreparedStatement prepareStatement(final String sql, final int 
resultSetType, final int resultSetConcurrency,
             final int resultSetHoldability) throws SQLException {
-        if (pStmtPool == null) {
+        if (stmtPool == null) {
             return getRawConnection().prepareStatement(sql, resultSetType, 
resultSetConcurrency, resultSetHoldability);
         }
         try {
-            return pStmtPool.borrowObject(createKey(sql, resultSetType, 
resultSetConcurrency, resultSetHoldability));
+            return stmtPool.borrowObject(createKey(sql, resultSetType, 
resultSetConcurrency, resultSetHoldability));
         } catch (final RuntimeException e) {
             throw e;
         } catch (final Exception e) {
@@ -661,11 +661,11 @@ final class PooledConnectionImpl
 
     @SuppressWarnings("resource") // getRawConnection() does not allocate
     PreparedStatement prepareStatement(final String sql, final int[] 
columnIndexes) throws SQLException {
-        if (pStmtPool == null) {
+        if (stmtPool == null) {
             return getRawConnection().prepareStatement(sql, columnIndexes);
         }
         try {
-            return pStmtPool.borrowObject(createKey(sql, columnIndexes));
+            return stmtPool.borrowObject(createKey(sql, columnIndexes));
         } catch (final RuntimeException e) {
             throw e;
         } catch (final Exception e) {
@@ -675,11 +675,11 @@ final class PooledConnectionImpl
 
     @SuppressWarnings("resource") // getRawConnection() does not allocate
     PreparedStatement prepareStatement(final String sql, final String[] 
columnNames) throws SQLException {
-        if (pStmtPool == null) {
+        if (stmtPool == null) {
             return getRawConnection().prepareStatement(sql, columnNames);
         }
         try {
-            return pStmtPool.borrowObject(createKey(sql, columnNames));
+            return stmtPool.borrowObject(createKey(sql, columnNames));
         } catch (final RuntimeException e) {
             throw e;
         } catch (final Exception e) {
@@ -712,7 +712,7 @@ final class PooledConnectionImpl
     }
 
     public void setStatementPool(final KeyedObjectPool<PStmtKey, 
DelegatingPreparedStatement> statementPool) {
-        pStmtPool = statementPool;
+        stmtPool = statementPool;
     }
 
     /**
@@ -733,8 +733,8 @@ final class PooledConnectionImpl
         builder.append(statementEventListeners);
         builder.append(", closed=");
         builder.append(closed);
-        builder.append(", pStmtPool=");
-        builder.append(pStmtPool);
+        builder.append(", stmtPool=");
+        builder.append(stmtPool);
         builder.append(", accessToUnderlyingConnectionAllowed=");
         builder.append(accessToUnderlyingConnectionAllowed);
         builder.append("]");

Reply via email to