commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1729274 [5/7] - in /commons/proper/dbcp/trunk/src: main/java/org/apache/commons/dbcp2/ main/java/org/apache/commons/dbcp2/cpdsadapter/ main/java/org/apache/commons/dbcp2/datasources/ main/java/org/apache/commons/dbcp2/managed/ test/java/or...
Date Mon, 08 Feb 2016 21:56:49 GMT
Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSourceFactory.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSourceFactory.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSourceFactory.java Mon Feb  8 21:56:48 2016
@@ -44,7 +44,7 @@ public class PerUserPoolDataSourceFactor
     @Override
     protected InstanceKeyDataSource getNewInstance(Reference ref)
         throws IOException, ClassNotFoundException {
-        PerUserPoolDataSource pupds =  new PerUserPoolDataSource();
+        final PerUserPoolDataSource pupds =  new PerUserPoolDataSource();
         RefAddr ra = ref.get("defaultMaxTotal");
         if (ra != null && ra.getContent() != null) {
             pupds.setDefaultMaxTotal(
@@ -65,42 +65,42 @@ public class PerUserPoolDataSourceFactor
 
         ra = ref.get("perUserDefaultAutoCommit");
         if (ra != null  && ra.getContent() != null) {
-            byte[] serialized = (byte[]) ra.getContent();
+            final byte[] serialized = (byte[]) ra.getContent();
             pupds.setPerUserDefaultAutoCommit(
                     (Map<String,Boolean>) deserialize(serialized));
         }
 
         ra = ref.get("perUserDefaultTransactionIsolation");
         if (ra != null  && ra.getContent() != null) {
-            byte[] serialized = (byte[]) ra.getContent();
+            final byte[] serialized = (byte[]) ra.getContent();
             pupds.setPerUserDefaultTransactionIsolation(
                     (Map<String,Integer>) deserialize(serialized));
         }
 
         ra = ref.get("perUserMaxTotal");
         if (ra != null  && ra.getContent() != null) {
-            byte[] serialized = (byte[]) ra.getContent();
+            final byte[] serialized = (byte[]) ra.getContent();
             pupds.setPerUserMaxTotal(
                     (Map<String,Integer>) deserialize(serialized));
         }
 
         ra = ref.get("perUserMaxIdle");
         if (ra != null  && ra.getContent() != null) {
-            byte[] serialized = (byte[]) ra.getContent();
+            final byte[] serialized = (byte[]) ra.getContent();
             pupds.setPerUserMaxIdle(
                     (Map<String,Integer>) deserialize(serialized));
         }
 
         ra = ref.get("perUserMaxWaitMillis");
         if (ra != null  && ra.getContent() != null) {
-            byte[] serialized = (byte[]) ra.getContent();
+            final byte[] serialized = (byte[]) ra.getContent();
             pupds.setPerUserMaxWaitMillis(
                     (Map<String,Long>) deserialize(serialized));
         }
 
         ra = ref.get("perUserDefaultReadOnly");
         if (ra != null  && ra.getContent() != null) {
-            byte[] serialized = (byte[]) ra.getContent();
+            final byte[] serialized = (byte[]) ra.getContent();
             pupds.setPerUserDefaultReadOnly(
                     (Map<String,Boolean>) deserialize(serialized));
         }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java Mon Feb  8 21:56:48 2016
@@ -37,7 +37,7 @@ class PoolKey implements Serializable {
     @Override
     public boolean equals(Object obj) {
         if (obj instanceof PoolKey) {
-            PoolKey pk = (PoolKey)obj;
+            final PoolKey pk = (PoolKey)obj;
             return (null == datasourceName ? null == pk.datasourceName : datasourceName.equals(pk.datasourceName)) &&
                 (null == username ? null == pk.username : username.equals(pk.username));
         }
@@ -58,7 +58,7 @@ class PoolKey implements Serializable {
 
     @Override
     public String toString() {
-        StringBuffer sb = new StringBuffer(50);
+        final StringBuffer sb = new StringBuffer(50);
         sb.append("PoolKey(");
         sb.append(username).append(", ").append(datasourceName);
         sb.append(')');

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=1729274&r1=1729273&r2=1729274&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  8 21:56:48 2016
@@ -126,7 +126,7 @@ public class SharedPoolDataSource extend
             if (pool == null) {
                 try {
                     registerPool(username, password);
-                } catch (NamingException e) {
+                } catch (final NamingException e) {
                     throw new SQLException("RegisterPool failed", e);
                 }
             }
@@ -134,12 +134,12 @@ public class SharedPoolDataSource extend
 
         PooledConnectionAndInfo info = null;
 
-        UserPassKey key = new UserPassKey(username, password);
+        final UserPassKey key = new UserPassKey(username, password);
 
         try {
             info = pool.borrowObject(key);
         }
-        catch (Exception e) {
+        catch (final Exception e) {
             throw new SQLException(
                     "Could not retrieve connection info from pool", e);
         }
@@ -156,7 +156,7 @@ public class SharedPoolDataSource extend
      */
     @Override
     public Reference getReference() throws NamingException {
-        Reference ref = new Reference(getClass().getName(),
+        final Reference ref = new Reference(getClass().getName(),
             SharedPoolDataSourceFactory.class.getName(), null);
         ref.add(new StringRefAddr("instanceKey", getInstanceKey()));
         return ref;
@@ -165,14 +165,14 @@ public class SharedPoolDataSource extend
     private void registerPool(String username, String password)
             throws NamingException, SQLException {
 
-        ConnectionPoolDataSource cpds = testCPDS(username, password);
+        final ConnectionPoolDataSource cpds = testCPDS(username, password);
 
         // Create an object pool to contain our PooledConnections
         factory = new KeyedCPDSConnectionFactory(cpds, getValidationQuery(),
                 getValidationQueryTimeout(), isRollbackAfterValidation());
         factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis());
 
-        GenericKeyedObjectPoolConfig config =
+        final GenericKeyedObjectPoolConfig config =
                 new GenericKeyedObjectPoolConfig();
         config.setBlockWhenExhausted(getDefaultBlockWhenExhausted());
         config.setEvictionPolicyClassName(getDefaultEvictionPolicyClassName());
@@ -194,7 +194,7 @@ public class SharedPoolDataSource extend
         config.setTimeBetweenEvictionRunsMillis(
                 getDefaultTimeBetweenEvictionRunsMillis());
 
-        KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> tmpPool =
+        final KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> tmpPool =
                 new GenericKeyedObjectPool<>(factory, config);
         factory.setPool(tmpPool);
         pool = tmpPool;
@@ -202,18 +202,18 @@ public class SharedPoolDataSource extend
 
     @Override
     protected void setupDefaults(Connection con, String username) throws SQLException {
-        Boolean defaultAutoCommit = isDefaultAutoCommit();
+        final Boolean defaultAutoCommit = isDefaultAutoCommit();
         if (defaultAutoCommit != null &&
                 con.getAutoCommit() != defaultAutoCommit.booleanValue()) {
             con.setAutoCommit(defaultAutoCommit.booleanValue());
         }
 
-        int defaultTransactionIsolation = getDefaultTransactionIsolation();
+        final int defaultTransactionIsolation = getDefaultTransactionIsolation();
         if (defaultTransactionIsolation != UNKNOWN_TRANSACTIONISOLATION) {
             con.setTransactionIsolation(defaultTransactionIsolation);
         }
 
-        Boolean defaultReadOnly = isDefaultReadOnly();
+        final Boolean defaultReadOnly = isDefaultReadOnly();
         if (defaultReadOnly != null &&
                 con.isReadOnly() != defaultReadOnly.booleanValue()) {
             con.setReadOnly(defaultReadOnly.booleanValue());
@@ -232,12 +232,12 @@ public class SharedPoolDataSource extend
         try
         {
             in.defaultReadObject();
-            SharedPoolDataSource oldDS = (SharedPoolDataSource)
+            final SharedPoolDataSource oldDS = (SharedPoolDataSource)
                 new SharedPoolDataSourceFactory()
                     .getObjectInstance(getReference(), null, null, null);
             this.pool = oldDS.pool;
         }
-        catch (NamingException e)
+        catch (final NamingException e)
         {
             throw new IOException("NamingException: " + e);
         }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSourceFactory.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSourceFactory.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/SharedPoolDataSourceFactory.java Mon Feb  8 21:56:48 2016
@@ -38,8 +38,8 @@ public class SharedPoolDataSourceFactory
 
     @Override
     protected InstanceKeyDataSource getNewInstance(Reference ref) {
-        SharedPoolDataSource spds = new SharedPoolDataSource();
-        RefAddr ra = ref.get("maxTotal");
+        final SharedPoolDataSource spds = new SharedPoolDataSource();
+        final RefAddr ra = ref.get("maxTotal");
         if (ra != null && ra.getContent() != null) {
             spds.setMaxTotal(
                 Integer.parseInt(ra.getContent().toString()));

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java Mon Feb  8 21:56:48 2016
@@ -78,7 +78,7 @@ class UserPassKey implements Serializabl
             return false;
         }
 
-        UserPassKey key = (UserPassKey) obj;
+        final UserPassKey key = (UserPassKey) obj;
 
         return this.username == null ?
                 key.username == null :
@@ -96,7 +96,7 @@ class UserPassKey implements Serializabl
 
     @Override
     public String toString() {
-        StringBuffer sb = new StringBuffer(50);
+        final StringBuffer sb = new StringBuffer(50);
         sb.append("UserPassKey(");
         sb.append(username).append(", ").append(password).append(')');
         return sb.toString();

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java Mon Feb  8 21:56:48 2016
@@ -135,8 +135,8 @@ public class BasicManagedDataSource exte
 
         // If xa data source is not specified a DriverConnectionFactory is created and wrapped with a LocalXAConnectionFactory
         if (xaDataSource == null) {
-            ConnectionFactory connectionFactory = super.createConnectionFactory();
-            XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(getTransactionManager(), connectionFactory);
+            final ConnectionFactory connectionFactory = super.createConnectionFactory();
+            final XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(getTransactionManager(), connectionFactory);
             transactionRegistry = xaConnectionFactory.getTransactionRegistry();
             return xaConnectionFactory;
         }
@@ -146,28 +146,28 @@ public class BasicManagedDataSource exte
             Class<?> xaDataSourceClass = null;
             try {
                 xaDataSourceClass = Class.forName(xaDataSource);
-            } catch (Exception t) {
-                String message = "Cannot load XA data source class '" + xaDataSource + "'";
+            } catch (final Exception t) {
+                final String message = "Cannot load XA data source class '" + xaDataSource + "'";
                 throw new SQLException(message, t);
             }
 
             try {
                 xaDataSourceInstance = (XADataSource) xaDataSourceClass.newInstance();
-            } catch (Exception t) {
-                String message = "Cannot create XA data source of class '" + xaDataSource + "'";
+            } catch (final Exception t) {
+                final String message = "Cannot create XA data source of class '" + xaDataSource + "'";
                 throw new SQLException(message, t);
             }
         }
 
         // finally, create the XAConectionFactory using the XA data source
-        XAConnectionFactory xaConnectionFactory = new DataSourceXAConnectionFactory(getTransactionManager(), xaDataSourceInstance, getUsername(), getPassword());
+        final XAConnectionFactory xaConnectionFactory = new DataSourceXAConnectionFactory(getTransactionManager(), xaDataSourceInstance, getUsername(), getPassword());
         transactionRegistry = xaConnectionFactory.getTransactionRegistry();
         return xaConnectionFactory;
     }
 
     @Override
     protected DataSource createDataSourceInstance() throws SQLException {
-        PoolingDataSource<PoolableConnection> pds =
+        final PoolingDataSource<PoolableConnection> pds =
                 new ManagedDataSource<>(getConnectionPool(), transactionRegistry);
         pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
         return pds;
@@ -204,9 +204,9 @@ public class BasicManagedDataSource exte
             connectionFactory.setFastFailValidation(getFastFailValidation());
             connectionFactory.setDisconnectionSqlCodes(getDisconnectionSqlCodes());
             validateConnectionFactory(connectionFactory);
-        } catch (RuntimeException e) {
+        } catch (final RuntimeException e) {
             throw e;
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new SQLException("Cannot create PoolableConnectionFactory (" + e.getMessage() + ")", e);
         }
         return connectionFactory;

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/DataSourceXAConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/DataSourceXAConnectionFactory.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/DataSourceXAConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/DataSourceXAConnectionFactory.java Mon Feb  8 21:56:48 2016
@@ -115,8 +115,8 @@ public class DataSourceXAConnectionFacto
         }
 
         // get the real connection and XAResource from the connection
-        Connection connection = xaConnection.getConnection();
-        XAResource xaResource = xaConnection.getXAResource();
+        final Connection connection = xaConnection.getConnection();
+        final XAResource xaResource = xaConnection.getXAResource();
 
         // register the xa resource for the connection
         transactionRegistry.registerConnection(connection, xaResource);
@@ -128,11 +128,11 @@ public class DataSourceXAConnectionFacto
 
             @Override
             public void connectionClosed(ConnectionEvent event) {
-                PooledConnection pc = (PooledConnection) event.getSource();
+                final PooledConnection pc = (PooledConnection) event.getSource();
                 pc.removeConnectionEventListener(this);
                 try {
                     pc.close();
-                } catch (SQLException e) {
+                } catch (final SQLException e) {
                     System.err.println("Failed to close XAConnection");
                     e.printStackTrace();
                 }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java Mon Feb  8 21:56:48 2016
@@ -66,10 +66,10 @@ public class LocalXAConnectionFactory im
     @Override
     public Connection createConnection() throws SQLException {
         // create a new connection
-        Connection connection = connectionFactory.createConnection();
+        final Connection connection = connectionFactory.createConnection();
 
         // create a XAResource to manage the connection during XA transactions
-        XAResource xaResource = new LocalXAResource(connection);
+        final XAResource xaResource = new LocalXAResource(connection);
 
         // register the xa resource for the connection
         transactionRegistry.registerConnection(connection, xaResource);
@@ -131,7 +131,7 @@ public class LocalXAConnectionFactory im
                 // save off the current auto commit flag so it can be restored after the transaction completes
                 try {
                     originalAutoCommit = connection.getAutoCommit();
-                } catch (SQLException ignored) {
+                } catch (final SQLException ignored) {
                     // no big deal, just assume it was off
                     originalAutoCommit = true;
                 }
@@ -139,7 +139,7 @@ public class LocalXAConnectionFactory im
                 // update the auto commit flag
                 try {
                     connection.setAutoCommit(false);
-                } catch (SQLException e) {
+                } catch (final SQLException e) {
                     throw (XAException) new XAException("Count not turn off auto commit for a XA transaction").initCause(e);
                 }
 
@@ -196,7 +196,7 @@ public class LocalXAConnectionFactory im
                     // tell the transaction manager we are read only
                     return XAResource.XA_RDONLY;
                 }
-            } catch (SQLException ignored) {
+            } catch (final SQLException ignored) {
                 // no big deal
             }
 
@@ -234,12 +234,12 @@ public class LocalXAConnectionFactory im
                 if (!connection.isReadOnly()) {
                     connection.commit();
                 }
-            } catch (SQLException e) {
+            } catch (final SQLException e) {
                 throw (XAException) new XAException().initCause(e);
             } finally {
                 try {
                     connection.setAutoCommit(originalAutoCommit);
-                } catch (SQLException e) {
+                } catch (final SQLException e) {
                 }
                 this.currentXid = null;
             }
@@ -262,12 +262,12 @@ public class LocalXAConnectionFactory im
 
             try {
                 connection.rollback();
-            } catch (SQLException e) {
+            } catch (final SQLException e) {
                 throw (XAException) new XAException().initCause(e);
             } finally {
                 try {
                     connection.setAutoCommit(originalAutoCommit);
-                } catch (SQLException e) {
+                } catch (final SQLException e) {
                 }
                 this.currentXid = null;
             }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java Mon Feb  8 21:56:48 2016
@@ -90,16 +90,16 @@ public class ManagedConnection<C extends
             // in the transaction, replace our delegate with the enrolled connection
 
             // return current connection to the pool
-            C connection = getDelegateInternal();
+            final C connection = getDelegateInternal();
             setDelegate(null);
             if (connection != null) {
                 try {
                     pool.returnObject(connection);
-                } catch (Exception ignored) {
+                } catch (final Exception ignored) {
                     // whatever... try to invalidate the connection
                     try {
                         pool.invalidateObject(connection);
-                    } catch (Exception ignore) {
+                    } catch (final Exception ignore) {
                         // no big deal
                     }
                 }
@@ -112,6 +112,7 @@ public class ManagedConnection<C extends
             // always be of type C since it has been shared by another
             // connection from the same pool.
             @SuppressWarnings("unchecked")
+            final
             C shared = (C) transactionContext.getSharedConnection();
             setDelegate(shared);
 
@@ -126,7 +127,7 @@ public class ManagedConnection<C extends
                     // borrow a new connection from the pool
                     connection = pool.borrowObject();
                     setDelegate(connection);
-                } catch (Exception e) {
+                } catch (final Exception e) {
                     throw new SQLException("Unable to acquire a new connection from the pool", e);
                 }
             }
@@ -139,12 +140,12 @@ public class ManagedConnection<C extends
                 // register our connection as the shared connection
                 try {
                     transactionContext.setSharedConnection(connection);
-                } catch (SQLException e) {
+                } catch (final SQLException e) {
                     // transaction is hosed
                     transactionContext = null;
                     try {
                         pool.invalidateObject(connection);
-                    } catch (Exception e1) {
+                    } catch (final Exception e1) {
                         // we are try but no luck
                     }
                     throw e;
@@ -197,7 +198,7 @@ public class ManagedConnection<C extends
 
         // If this connection was closed during the transaction and there is
         // still a delegate present close it
-        Connection delegate = getDelegateInternal();
+        final Connection delegate = getDelegateInternal();
         if (isClosedInternal() && delegate != null) {
             try {
                 setDelegate(null);
@@ -205,7 +206,7 @@ public class ManagedConnection<C extends
                 if (!delegate.isClosed()) {
                     delegate.close();
                 }
-            } catch (SQLException ignored) {
+            } catch (final SQLException ignored) {
                 // Not a whole lot we can do here as connection is closed
                 // and this is a transaction callback so there is no
                 // way to report the error.

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java Mon Feb  8 21:56:48 2016
@@ -79,7 +79,7 @@ public class ManagedDataSource<C extends
             throw new IllegalStateException("TransactionRegistry has not been set");
         }
 
-        Connection connection = new ManagedConnection<>(getPool(), transactionRegistry, isAccessToUnderlyingConnectionAllowed());
+        final Connection connection = new ManagedConnection<>(getPool(), transactionRegistry, isAccessToUnderlyingConnectionAllowed());
         return connection;
     }
 }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/PoolableManagedConnectionFactory.java Mon Feb  8 21:56:48 2016
@@ -70,16 +70,16 @@ public class PoolableManagedConnectionFa
         initializeConnection(conn);
         if (getPoolStatements()) {
             conn = new PoolingConnection(conn);
-            GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
+            final GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
             config.setMaxTotalPerKey(-1);
             config.setBlockWhenExhausted(false);
             config.setMaxWaitMillis(0);
             config.setMaxIdlePerKey(1);
             config.setMaxTotal(getMaxOpenPreparedStatements());
-            ObjectName dataSourceJmxName = getDataSourceJmxName();
-            long connIndex = getConnectionIndex().getAndIncrement();
+            final ObjectName dataSourceJmxName = getDataSourceJmxName();
+            final long connIndex = getConnectionIndex().getAndIncrement();
             if (dataSourceJmxName != null) {
-                StringBuilder base = new StringBuilder(dataSourceJmxName.toString());
+                final StringBuilder base = new StringBuilder(dataSourceJmxName.toString());
                 base.append(Constants.JMX_CONNECTION_BASE_EXT);
                 base.append(Long.toString(connIndex));
                 config.setJmxNameBase(base.toString());
@@ -87,7 +87,7 @@ public class PoolableManagedConnectionFa
             } else {
                 config.setJmxEnabled(false);
             }
-            KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> stmtPool =
+            final KeyedObjectPool<PStmtKey,DelegatingPreparedStatement> stmtPool =
                 new GenericKeyedObjectPool<>((PoolingConnection)conn, config);
             ((PoolingConnection)conn).setStatementPool(stmtPool);
             ((PoolingConnection) conn).setCacheState(getCacheState());

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/TransactionContext.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/TransactionContext.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/TransactionContext.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/TransactionContext.java Mon Feb  8 21:56:48 2016
@@ -88,15 +88,15 @@ public class TransactionContext {
 
         // This is the first use of the connection in this transaction, so we must
         // enlist it in the transaction
-        Transaction transaction = getTransaction();
+        final Transaction transaction = getTransaction();
         try {
-            XAResource xaResource = transactionRegistry.getXAResource(sharedConnection);
+            final XAResource xaResource = transactionRegistry.getXAResource(sharedConnection);
             if ( !transaction.enlistResource(xaResource) ) {
                 throw new SQLException("Unable to enlist connection in transaction: enlistResource returns 'false'.");
             }
-        } catch (RollbackException e) {
+        } catch (final RollbackException e) {
             // transaction was rolled back... proceed as if there never was a transaction
-        } catch (SystemException e) {
+        } catch (final SystemException e) {
             throw new SQLException("Unable to enlist connection the transaction", e);
         }
 
@@ -121,10 +121,10 @@ public class TransactionContext {
                     listener.afterCompletion(TransactionContext.this, status == Status.STATUS_COMMITTED);
                 }
             });
-        } catch (RollbackException e) {
+        } catch (final RollbackException e) {
             // JTA spec doesn't let us register with a transaction marked rollback only
             // just ignore this and the tx state will be cleared another way.
-        } catch (Exception e) {
+        } catch (final Exception e) {
             throw new SQLException("Unable to register transaction context listener", e);
         }
     }
@@ -136,19 +136,19 @@ public class TransactionContext {
      */
     public boolean isActive() throws SQLException {
         try {
-            Transaction transaction = this.transactionRef.get();
+            final Transaction transaction = this.transactionRef.get();
             if (transaction == null) {
                 return false;
             }
-            int status = transaction.getStatus();
+            final int status = transaction.getStatus();
             return status == Status.STATUS_ACTIVE || status == Status.STATUS_MARKED_ROLLBACK;
-        } catch (SystemException e) {
+        } catch (final SystemException e) {
             throw new SQLException("Unable to get transaction status", e);
         }
     }
 
     private Transaction getTransaction() throws SQLException {
-        Transaction transaction = this.transactionRef.get();
+        final Transaction transaction = this.transactionRef.get();
         if (transaction == null) {
             throw new SQLException("Unable to enlist connection because the transaction has been garbage collected");
         }

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java (original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java Mon Feb  8 21:56:48 2016
@@ -83,8 +83,8 @@ public class TransactionRegistry {
         if (connection == null) {
             throw new NullPointerException("connection is null");
         }
-        Connection key = getConnectionKey(connection);
-        XAResource xaResource = xaResources.get(key);
+        final Connection key = getConnectionKey(connection);
+        final XAResource xaResource = xaResources.get(key);
         if (xaResource == null) {
             throw new SQLException("Connection does not have a registered XAResource " + connection);
         }
@@ -107,11 +107,11 @@ public class TransactionRegistry {
             }
 
             // is it active
-            int status = transaction.getStatus();
+            final int status = transaction.getStatus();
             if (status != Status.STATUS_ACTIVE && status != Status.STATUS_MARKED_ROLLBACK) {
                 return null;
             }
-        } catch (SystemException e) {
+        } catch (final SystemException e) {
             throw new SQLException("Unable to determine current transaction ", e);
         }
 
@@ -131,7 +131,7 @@ public class TransactionRegistry {
      * @param connection
      */
     public synchronized void unregisterConnection(Connection connection) {
-        Connection key = getConnectionKey(connection);
+        final Connection key = getConnectionKey(connection);
         xaResources.remove(key);
     }
 

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java (original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java Mon Feb  8 21:56:48 2016
@@ -76,7 +76,7 @@ public class StackMessageLog extends Sim
         lock.lock();
         try {
             ret = messageStack.pop();
-        } catch (EmptyStackException ex) {
+        } catch (final EmptyStackException ex) {
             // ignore, return null
         } finally {
             lock.unlock();
@@ -122,7 +122,7 @@ public class StackMessageLog extends Sim
     public static void unLock() {
         try {
             lock.unlock();
-        } catch (IllegalMonitorStateException ex) {
+        } catch (final IllegalMonitorStateException ex) {
             // ignore
         }
     }

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestAbandonedBasicDataSource.java Mon Feb  8 21:56:48 2016
@@ -79,11 +79,11 @@ public class TestAbandonedBasicDataSourc
         ds.setMaxTotal(1);
         ds.setAccessToUnderlyingConnectionAllowed(true);
 
-        Connection conn1 = getConnection();
+        final Connection conn1 = getConnection();
         assertNotNull(conn1);
         assertEquals(1, ds.getNumActive());
 
-        Connection conn2 = getConnection();
+        final Connection conn2 = getConnection();
         // Attempt to borrow object triggers abandoned cleanup
         // conn1 should be closed by the pool to make room
         assertNotNull(conn2);
@@ -107,28 +107,28 @@ public class TestAbandonedBasicDataSourc
         ds.setMaxTotal(1);
         ds.setAccessToUnderlyingConnectionAllowed(true);
 
-        Connection conn1 = getConnection();
+        final Connection conn1 = getConnection();
         assertNotNull(conn1);
         assertEquals(1, ds.getNumActive());
 
-        Connection conn2 = getConnection();
+        final Connection conn2 = getConnection();
         assertNotNull(conn2);
         assertEquals(1, ds.getNumActive());
 
         // set an IO failure causing the isClosed mathod to fail
-        TesterConnection tconn1 = (TesterConnection) ((DelegatingConnection<?>)conn1).getInnermostDelegate();
+        final TesterConnection tconn1 = (TesterConnection) ((DelegatingConnection<?>)conn1).getInnermostDelegate();
         tconn1.setFailure(new IOException("network error"));
-        TesterConnection tconn2 = (TesterConnection) ((DelegatingConnection<?>)conn2).getInnermostDelegate();
+        final TesterConnection tconn2 = (TesterConnection) ((DelegatingConnection<?>)conn2).getInnermostDelegate();
         tconn2.setFailure(new IOException("network error"));
 
         try {
             conn2.close();
-        } catch (SQLException ex) {
+        } catch (final SQLException ex) {
             /* Ignore */
         }
         assertEquals(0, ds.getNumActive());
 
-        try { conn1.close(); } catch (SQLException ex) { }
+        try { conn1.close(); } catch (final SQLException ex) { }
         assertEquals(0, ds.getNumActive());
         assertTrue(sw.toString().contains("testAbandonedCloseWithExceptions"));
     }
@@ -145,7 +145,7 @@ public class TestAbandonedBasicDataSourc
             Thread.sleep(500);
             try (Statement s = conn1.createStatement()) {} // Should reset lastUsed
             Thread.sleep(800);
-            Connection conn2 = ds.getConnection(); // triggers abandoned cleanup
+            final Connection conn2 = ds.getConnection(); // triggers abandoned cleanup
             try (Statement s = conn1.createStatement()) {} // Should still be OK
             conn2.close();
             Thread.sleep(500);
@@ -168,7 +168,7 @@ public class TestAbandonedBasicDataSourc
             Thread.sleep(500);
             try (CallableStatement cs = conn1.prepareCall("{call home}")) {} // Should reset lastUsed
             Thread.sleep(800);
-            Connection conn2 = ds.getConnection(); // triggers abandoned cleanup
+            final Connection conn2 = ds.getConnection(); // triggers abandoned cleanup
             try (CallableStatement cs = conn1.prepareCall("{call home}")) {} // Should still be OK
             conn2.close();
             Thread.sleep(500);
@@ -189,11 +189,11 @@ public class TestAbandonedBasicDataSourc
         ds.setMaxTotal(2);
         try (Connection conn1 = ds.getConnection();
                 Statement st = conn1.createStatement()) {
-            String querySQL = "SELECT 1 FROM DUAL";
+            final String querySQL = "SELECT 1 FROM DUAL";
             Thread.sleep(500);
             Assert.assertNotNull(st.executeQuery(querySQL)); // Should reset lastUsed
             Thread.sleep(800);
-            Connection conn2 = ds.getConnection(); // triggers abandoned cleanup
+            final Connection conn2 = ds.getConnection(); // triggers abandoned cleanup
             Assert.assertNotNull(st.executeQuery(querySQL)); // Should still be OK
             conn2.close();
             Thread.sleep(500);
@@ -210,10 +210,10 @@ public class TestAbandonedBasicDataSourc
      */
     @Test
     public void testLastUsedUpdate() throws Exception {
-        DelegatingConnection<?> conn = (DelegatingConnection<?>) ds.getConnection();
-        PreparedStatement ps = conn.prepareStatement("");
-        CallableStatement cs = conn.prepareCall("");
-        Statement st = conn.prepareStatement("");
+        final DelegatingConnection<?> conn = (DelegatingConnection<?>) ds.getConnection();
+        final PreparedStatement ps = conn.prepareStatement("");
+        final CallableStatement cs = conn.prepareCall("");
+        final Statement st = conn.prepareStatement("");
         checkLastUsedStatement(ps, conn);
         checkLastUsedPreparedStatement(ps, conn);
         checkLastUsedStatement(cs, conn);
@@ -228,7 +228,7 @@ public class TestAbandonedBasicDataSourc
      */
     @Test
     public void testGarbageCollectorCleanUp01() throws Exception {
-        DelegatingConnection<?> conn = (DelegatingConnection<?>) ds.getConnection();
+        final DelegatingConnection<?> conn = (DelegatingConnection<?>) ds.getConnection();
         Assert.assertEquals(0, conn.getTrace().size());
         createStatement(conn);
         Assert.assertEquals(1, conn.getTrace().size());
@@ -243,10 +243,11 @@ public class TestAbandonedBasicDataSourc
     public void testGarbageCollectorCleanUp02() throws Exception {
         ds.setPoolPreparedStatements(true);
         ds.setAccessToUnderlyingConnectionAllowed(true);
-        DelegatingConnection<?> conn = (DelegatingConnection<?>) ds.getConnection();
-        PoolableConnection poolableConn = (PoolableConnection) conn.getDelegate();
-        PoolingConnection poolingConn = (PoolingConnection) poolableConn.getDelegate();
+        final DelegatingConnection<?> conn = (DelegatingConnection<?>) ds.getConnection();
+        final PoolableConnection poolableConn = (PoolableConnection) conn.getDelegate();
+        final PoolingConnection poolingConn = (PoolingConnection) poolableConn.getDelegate();
         @SuppressWarnings("unchecked")
+        final
         GenericKeyedObjectPool<PStmtKey,DelegatingPreparedStatement>  gkop =
                 (GenericKeyedObjectPool<PStmtKey,DelegatingPreparedStatement>) TesterUtils.getField(poolingConn, "_pstmtPool");
         Assert.assertEquals(0, conn.getTrace().size());
@@ -267,7 +268,7 @@ public class TestAbandonedBasicDataSourc
     }
 
     private void createStatement(Connection conn) throws Exception{
-        PreparedStatement ps = conn.prepareStatement("");
+        final PreparedStatement ps = conn.prepareStatement("");
         Assert.assertNotNull(ps);
     }
 

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java Mon Feb  8 21:56:48 2016
@@ -97,14 +97,14 @@ public class TestBasicDataSource extends
         ds.setAccessToUnderlyingConnectionAllowed(true);
 
         // active connection is held open when ds is closed
-        Connection activeConnection = getConnection();
-        Connection rawActiveConnection = ((DelegatingConnection<?>) activeConnection).getInnermostDelegate();
+        final Connection activeConnection = getConnection();
+        final Connection rawActiveConnection = ((DelegatingConnection<?>) activeConnection).getInnermostDelegate();
         assertFalse(activeConnection.isClosed());
         assertFalse(rawActiveConnection.isClosed());
 
         // idle connection is in pool but closed
-        Connection idleConnection = getConnection();
-        Connection rawIdleConnection = ((DelegatingConnection<?>) idleConnection).getInnermostDelegate();
+        final Connection idleConnection = getConnection();
+        final Connection rawIdleConnection = ((DelegatingConnection<?>) idleConnection).getInnermostDelegate();
         assertFalse(idleConnection.isClosed());
         assertFalse(rawIdleConnection.isClosed());
 
@@ -133,7 +133,7 @@ public class TestBasicDataSource extends
         try {
             getConnection();
             fail("Expecting SQLException");
-        } catch (SQLException ex) {
+        } catch (final SQLException ex) {
             // Expected
         }
 
@@ -189,23 +189,23 @@ public class TestBasicDataSource extends
         try {
             ds.setConnectionProperties(null);
             fail("Expected NullPointerException");
-        } catch (NullPointerException e) {
+        } catch (final NullPointerException e) {
             // expected
         }
     }
 
     @Test
     public void testTransactionIsolationBehavior() throws Exception {
-        Connection conn = getConnection();
+        final Connection conn = getConnection();
         assertNotNull(conn);
         assertEquals(Connection.TRANSACTION_READ_COMMITTED, conn.getTransactionIsolation());
         conn.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
         conn.close();
 
-        Connection conn2 = getConnection();
+        final Connection conn2 = getConnection();
         assertEquals(Connection.TRANSACTION_READ_COMMITTED, conn2.getTransactionIsolation());
 
-        Connection conn3 = getConnection();
+        final Connection conn3 = getConnection();
         assertEquals(Connection.TRANSACTION_READ_COMMITTED, conn3.getTransactionIsolation());
 
         conn2.close();
@@ -226,7 +226,7 @@ public class TestBasicDataSource extends
         // default: false
         assertEquals(false, ds.isAccessToUnderlyingConnectionAllowed());
 
-        Connection conn = getConnection();
+        final Connection conn = getConnection();
         Connection dconn = ((DelegatingConnection<?>) conn).getDelegate();
         assertNull(dconn);
 
@@ -239,7 +239,7 @@ public class TestBasicDataSource extends
         ds.setAccessToUnderlyingConnectionAllowed(true);
         assertEquals(true, ds.isAccessToUnderlyingConnectionAllowed());
 
-        Connection conn = getConnection();
+        final Connection conn = getConnection();
         Connection dconn = ((DelegatingConnection<?>) conn).getDelegate();
         assertNotNull(dconn);
 
@@ -265,7 +265,7 @@ public class TestBasicDataSource extends
         ds.setValidationQuery("invalid");
         try (Connection c = ds.getConnection()) {
             fail("expected SQLException");
-        } catch (SQLException e) {
+        } catch (final SQLException e) {
             if (e.toString().indexOf("invalid") < 0) {
                 fail("expected detailed error message");
             }
@@ -278,7 +278,7 @@ public class TestBasicDataSource extends
         ds.setValidationQueryTimeout(3); // Too fast for TesterStatement
         try (Connection c = ds.getConnection()) {
             fail("expected SQLException");
-        } catch (SQLException ex) {
+        } catch (final SQLException ex) {
             if (ex.toString().indexOf("timeout") < 0) {
                 fail("expected timeout error message");
             }
@@ -290,7 +290,7 @@ public class TestBasicDataSource extends
         ds.setTestOnBorrow(true);
         ds.setTestOnReturn(true);
         ds.setValidationQueryTimeout(0);
-        Connection con = ds.getConnection();
+        final Connection con = ds.getConnection();
         con.close();
     }
 
@@ -299,7 +299,7 @@ public class TestBasicDataSource extends
         ds.setTestOnBorrow(true);
         ds.setTestOnReturn(true);
         ds.setValidationQueryTimeout(-1);
-        Connection con = ds.getConnection();
+        final Connection con = ds.getConnection();
         con.close();
     }
 
@@ -308,7 +308,7 @@ public class TestBasicDataSource extends
         ds.setTestOnBorrow(true);
         ds.setTestOnReturn(true);
         ds.setValidationQueryTimeout(100); // Works for TesterStatement
-        Connection con = ds.getConnection();
+        final Connection con = ds.getConnection();
         con.close();
     }
 
@@ -330,7 +330,7 @@ public class TestBasicDataSource extends
             try (Connection c = ds.getConnection()) {}
             fail("expected SQLException");
         }
-        catch (SQLException e) {
+        catch (final SQLException e) {
             if (e.toString().indexOf("invalid") < 0) {
                 fail("expected detailed error message");
             }
@@ -361,14 +361,14 @@ public class TestBasicDataSource extends
 
     @Test
     public void testDefaultCatalog() throws Exception {
-        Connection[] c = new Connection[getMaxTotal()];
+        final Connection[] c = new Connection[getMaxTotal()];
         for (int i = 0; i < c.length; i++) {
             c[i] = getConnection();
             assertTrue(c[i] != null);
             assertEquals(CATALOG, c[i].getCatalog());
         }
 
-        for (Connection element : c) {
+        for (final Connection element : c) {
             element.setCatalog("error");
             element.close();
         }
@@ -379,7 +379,7 @@ public class TestBasicDataSource extends
             assertEquals(CATALOG, c[i].getCatalog());
         }
 
-        for (Connection element : c) {
+        for (final Connection element : c) {
             element.close();
         }
     }
@@ -389,11 +389,11 @@ public class TestBasicDataSource extends
         ds.setAccessToUnderlyingConnectionAllowed(true);
         ds.setDefaultAutoCommit(Boolean.FALSE);
 
-        Connection conn = getConnection();
+        final Connection conn = getConnection();
         assertNotNull(conn);
         assertEquals(false, conn.getAutoCommit());
 
-        Connection dconn = ((DelegatingConnection<?>) conn).getInnermostDelegate();
+        final Connection dconn = ((DelegatingConnection<?>) conn).getInnermostDelegate();
         assertNotNull(dconn);
         assertEquals(false, dconn.getAutoCommit());
 
@@ -408,7 +408,7 @@ public class TestBasicDataSource extends
         ds.setMaxIdle(20);
         ds.setInitialSize(10);
 
-        Connection conn = getConnection();
+        final Connection conn = getConnection();
         assertNotNull(conn);
         conn.close();
 
@@ -421,19 +421,19 @@ public class TestBasicDataSource extends
     @Test
     public void testIsClosedFailure() throws SQLException {
         ds.setAccessToUnderlyingConnectionAllowed(true);
-        Connection conn = ds.getConnection();
+        final Connection conn = ds.getConnection();
         assertNotNull(conn);
         assertEquals(1, ds.getNumActive());
 
         // set an IO failure causing the isClosed method to fail
-        TesterConnection tconn = (TesterConnection) ((DelegatingConnection<?>)conn).getInnermostDelegate();
+        final TesterConnection tconn = (TesterConnection) ((DelegatingConnection<?>)conn).getInnermostDelegate();
         tconn.setFailure(new IOException("network error"));
 
         try {
             conn.close();
             fail("Expected SQLException");
         }
-        catch(SQLException ex) { }
+        catch(final SQLException ex) { }
 
         assertEquals(0, ds.getNumActive());
     }
@@ -448,8 +448,8 @@ public class TestBasicDataSource extends
         ds.setAccessToUnderlyingConnectionAllowed(true);  // Allow dirty tricks
 
         // Get an idle connection into the pool
-        Connection conn = ds.getConnection();
-        TesterConnection tc = (TesterConnection) ((DelegatingConnection<?>) conn).getInnermostDelegate();
+        final Connection conn = ds.getConnection();
+        final TesterConnection tc = (TesterConnection) ((DelegatingConnection<?>) conn).getInnermostDelegate();
         conn.close();
 
         // After returning the connection to the pool, bork it.
@@ -465,7 +465,7 @@ public class TestBasicDataSource extends
             ds.close();
             // Exception must have been swallowed by the pool - verify it is logged
             assertTrue(StackMessageLog.popMessage().indexOf("bang") > 0);
-        } catch (SQLException ex) {
+        } catch (final SQLException ex) {
             assertTrue(ex.getMessage().indexOf("Cannot close") > 0);
             assertTrue(ex.getCause().getMessage().indexOf("bang") > 0);
         } finally {
@@ -477,8 +477,8 @@ public class TestBasicDataSource extends
     public void testPoolCloseRTE() throws Exception {
         // RTE version of testPoolCloseCheckedException - see comments there.
         ds.setAccessToUnderlyingConnectionAllowed(true);
-        Connection conn = ds.getConnection();
-        TesterConnection tc = (TesterConnection) ((DelegatingConnection<?>) conn).getInnermostDelegate();
+        final Connection conn = ds.getConnection();
+        final TesterConnection tc = (TesterConnection) ((DelegatingConnection<?>) conn).getInnermostDelegate();
         conn.close();
         tc.setFailure(new IllegalStateException("boom"));
         try {
@@ -486,7 +486,7 @@ public class TestBasicDataSource extends
             StackMessageLog.clear();
             ds.close();
             assertTrue(StackMessageLog.popMessage().indexOf("boom") > 0);
-        } catch (IllegalStateException ex) {
+        } catch (final IllegalStateException ex) {
             assertTrue(ex.getMessage().indexOf("boom") > 0); // RTE is not wrapped by BDS#close
         } finally {
             StackMessageLog.unLock();
@@ -505,7 +505,7 @@ public class TestBasicDataSource extends
         ds.setTestWhileIdle(false);
         ds.setTestOnReturn(true);
 
-        Connection conn = ds.getConnection();
+        final Connection conn = ds.getConnection();
         assertNotNull(conn);
 
         assertEquals(false, ds.getConnectionPool().getTestOnBorrow());
@@ -523,7 +523,7 @@ public class TestBasicDataSource extends
         ds.setDefaultReadOnly(Boolean.TRUE);
         ds.setDefaultAutoCommit(Boolean.FALSE);
 
-        Connection conn = ds.getConnection();
+        final Connection conn = ds.getConnection();
         assertNotNull(conn);
         conn.close();
     }
@@ -538,11 +538,11 @@ public class TestBasicDataSource extends
         ds.setMaxTotal(0);
 
         try {
-            Connection conn = ds.getConnection();
+            final Connection conn = ds.getConnection();
             assertNotNull(conn);
             fail("SQLException expected");
 
-        } catch (SQLException e) {
+        } catch (final SQLException e) {
             // test OK
         }
     }
@@ -550,13 +550,13 @@ public class TestBasicDataSource extends
     @Test
     public void testInvalidateConnection() throws Exception {
     	ds.setMaxTotal(2);
-    	Connection conn1 = ds.getConnection();
-    	Connection conn2 = ds.getConnection();
+    	final Connection conn1 = ds.getConnection();
+    	final Connection conn2 = ds.getConnection();
     	ds.invalidateConnection(conn1);
     	assertTrue(conn1.isClosed());
     	assertEquals(1, ds.getNumActive());
     	assertEquals(0, ds.getNumIdle());
-    	Connection conn3 = ds.getConnection();
+    	final Connection conn3 = ds.getConnection();
     	conn2.close();
     	conn3.close();
     }
@@ -584,10 +584,10 @@ public class TestBasicDataSource extends
         // Make password incorrect, so createDataSource will throw
         ds.setPassword("wrong");
         ds.setValidationQuery("SELECT DUMMY FROM DUAL");
-        int threadCount = Thread.activeCount();
+        final int threadCount = Thread.activeCount();
         for (int i = 0; i < 10; i++) {
             try (Connection c = ds.getConnection()){
-            } catch (SQLException ex) {
+            } catch (final SQLException ex) {
                 // ignore
             }
         }
@@ -602,7 +602,7 @@ public class TestBasicDataSource extends
     @Test
     public void testDriverClassLoader() throws Exception {
         getConnection();
-        ClassLoader cl = ds.getDriverClassLoader();
+        final ClassLoader cl = ds.getDriverClassLoader();
         assertNotNull(cl);
         assertTrue(cl instanceof TesterClassLoader);
         assertTrue(((TesterClassLoader) cl).didLoad(ds.getDriverClassName()));
@@ -638,8 +638,9 @@ public class TestBasicDataSource extends
             for (int i=0; i<10; i++) {
                 try {
                     @SuppressWarnings("unused")
+                    final
                     DataSource ds2 = ds.createDataSource();
-                } catch (SQLException e) {
+                } catch (final SQLException e) {
                     // Ignore
                 }
             }
@@ -660,12 +661,12 @@ public class TestBasicDataSource extends
         try {
             StackMessageLog.lock();
             ds.setMaxConnLifetimeMillis(100);
-            Connection conn = ds.getConnection();
+            final Connection conn = ds.getConnection();
             assertEquals(1, ds.getNumActive());
             Thread.sleep(500);
             conn.close();
             assertEquals(0, ds.getNumIdle());
-            String message = StackMessageLog.popMessage();
+            final String message = StackMessageLog.popMessage();
             assertTrue(message.indexOf("exceeds the maximum permitted value") > 0);
         } finally {
             StackMessageLog.clear();
@@ -680,7 +681,7 @@ public class TestBasicDataSource extends
             StackMessageLog.clear();
             ds.setMaxConnLifetimeMillis(100);
             ds.setLogExpiredConnections(false);
-            Connection conn = ds.getConnection();
+            final Connection conn = ds.getConnection();
             assertEquals(1, ds.getNumActive());
             Thread.sleep(500);
             conn.close();
@@ -699,8 +700,8 @@ public class TestBasicDataSource extends
         ds.setInitialSize(8);
 
         // Launch a request to trigger pool initialization
-        TestThread testThread = new TestThread(1,0);
-        Thread t = new Thread(testThread);
+        final TestThread testThread = new TestThread(1,0);
+        final Thread t = new Thread(testThread);
         t.start();
 
         // Get another connection (should wait for pool init)
@@ -733,16 +734,16 @@ public class TestBasicDataSource extends
         ds.setMaxWaitMillis(-1);
         
         // Threads just borrow and return - validation will trigger close check
-        TestThread testThread1 = new TestThread(1000,0);
-        Thread t1 = new Thread(testThread1);
+        final TestThread testThread1 = new TestThread(1000,0);
+        final Thread t1 = new Thread(testThread1);
         t1.start();
-        TestThread testThread2 = new TestThread(1000,0);
-        Thread t2 = new Thread(testThread1);
+        final TestThread testThread2 = new TestThread(1000,0);
+        final Thread t2 = new Thread(testThread1);
         t2.start();
         
         // Grab and invalidate connections
         for (int i = 0; i < 1000; i++) {
-            Connection conn = ds.getConnection();
+            final Connection conn = ds.getConnection();
             ds.invalidateConnection(conn);
         }
         
@@ -761,11 +762,11 @@ public class TestBasicDataSource extends
      */
     @Test
     public void testJmxDisabled() throws Exception {
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
         // Unregister leftovers from other tests (TODO: worry about concurrent test execution)
-        ObjectName commons = new ObjectName("org.apache.commons.*:*");
-        Set<ObjectName> results = mbs.queryNames(commons, null);
-        for (ObjectName result : results) {
+        final ObjectName commons = new ObjectName("org.apache.commons.*:*");
+        final Set<ObjectName> results = mbs.queryNames(commons, null);
+        for (final ObjectName result : results) {
             mbs.unregisterMBean(result);
         }
         ds.setJmxName(null);  // Should disable JMX for both connection and statement pools
@@ -782,13 +783,13 @@ public class TestBasicDataSource extends
      */
     @Test
     public void testDisconnectSqlCodes() throws Exception {
-        ArrayList<String> disconnectionSqlCodes = new ArrayList<>();
+        final ArrayList<String> disconnectionSqlCodes = new ArrayList<>();
         disconnectionSqlCodes.add("XXX");
         ds.setDisconnectionSqlCodes(disconnectionSqlCodes);
         ds.setFastFailValidation(true);
         ds.getConnection();  // Triggers initialization - pcf creation
         // Make sure factory got the properties
-        PoolableConnectionFactory pcf =
+        final PoolableConnectionFactory pcf =
                 (PoolableConnectionFactory) ds.getConnectionPool().getFactory();
         assertTrue(pcf.isFastFailValidation());
         assertTrue(pcf.getDisconnectionSqlCodes().contains("XXX"));
@@ -832,11 +833,11 @@ class TesterConnectionDelayDriver extend
 
     @Override
     public Connection connect(String url, Properties info) throws SQLException {
-        String[] parsedUrl = url.split(":");
-        int delay = Integer.parseInt(parsedUrl[parsedUrl.length - 1]);
+        final String[] parsedUrl = url.split(":");
+        final int delay = Integer.parseInt(parsedUrl[parsedUrl.length - 1]);
         try {
             Thread.sleep(delay);
-        } catch(InterruptedException ex) {
+        } catch(final InterruptedException ex) {
             Thread.currentThread().interrupt();
         }
         return super.connect(url, info);

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java?rev=1729274&r1=1729273&r2=1729274&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java (original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/TestBasicDataSourceFactory.java Mon Feb  8 21:56:48 2016
@@ -43,15 +43,15 @@ public class TestBasicDataSourceFactory
 
     @Test
     public void testNoProperties() throws Exception {
-        Properties properties = new Properties();
-        BasicDataSource ds = BasicDataSourceFactory.createDataSource(properties);
+        final Properties properties = new Properties();
+        final BasicDataSource ds = BasicDataSourceFactory.createDataSource(properties);
 
         assertNotNull(ds);
     }
 
     @Test
     public void testProperties() throws Exception {
-        BasicDataSource ds = BasicDataSourceFactory.createDataSource(getTestProperties());
+        final BasicDataSource ds = BasicDataSourceFactory.createDataSource(getTestProperties());
         checkDataSourceProperties(ds);
     }
 
@@ -69,7 +69,7 @@ public class TestBasicDataSourceFactory
             basicDataSourceFactory.getObjectInstance(ref, null, null, null);
             final List<String> messages = StackMessageLog.getAll();
             assertEquals(2,messages.size());
-            for (String message : messages) {
+            for (final String message : messages) {
                 if (message.contains("maxWait")) {
                     assertTrue(message.contains("use maxWaitMillis"));
                 } else {
@@ -90,12 +90,12 @@ public class TestBasicDataSourceFactory
             StackMessageLog.clear();
             final Reference ref = new Reference("javax.sql.DataSource",
                                           BasicDataSourceFactory.class.getName(), null);
-            Properties properties = getTestProperties();
-            for (Entry<Object, Object> entry : properties.entrySet()) {
+            final Properties properties = getTestProperties();
+            for (final Entry<Object, Object> entry : properties.entrySet()) {
                 ref.add(new StringRefAddr((String) entry.getKey(), (String) entry.getValue()));
             }
             final BasicDataSourceFactory basicDataSourceFactory = new BasicDataSourceFactory();
-            BasicDataSource ds = (BasicDataSource) basicDataSourceFactory.getObjectInstance(ref, null, null, null);
+            final BasicDataSource ds = (BasicDataSource) basicDataSourceFactory.getObjectInstance(ref, null, null, null);
             checkDataSourceProperties(ds);
             final List<String> messages = StackMessageLog.getAll();
             assertEquals(0,messages.size());
@@ -106,7 +106,7 @@ public class TestBasicDataSourceFactory
     }
 
     private Properties getTestProperties() {
-        Properties properties = new Properties();
+        final Properties properties = new Properties();
         properties.setProperty("driverClassName", "org.apache.commons.dbcp2.TesterDriver");
         properties.setProperty("url", "jdbc:apache:commons:testdriver");
         properties.setProperty("maxTotal", "10");
@@ -187,7 +187,7 @@ public class TestBasicDataSourceFactory
         assertEquals("org.apache.commons.dbcp2:name=test", ds.getJmxName());
 
         // Unregister so subsequent calls to getTestProperties can re-register
-        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+        final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
         mbs.unregisterMBean(ds.getRegisteredJmxName());
     }
 }



Mime
View raw message