Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java Mon Feb 8 21:56:48 2016 @@ -65,7 +65,7 @@ public class TestDriverAdapterCPDS { // Use bad password pcds.getPooledConnection("u1", "zlsafjk"); fail("Able to retrieve connection with incorrect password"); - } catch (SQLException e1) { + } catch (final SQLException e1) { // should fail } @@ -76,7 +76,7 @@ public class TestDriverAdapterCPDS { pcds.getPooledConnection("u1", "x"); fail("Able to retrieve connection with incorrect password"); } - catch (SQLException e) { + catch (final SQLException e) { if (!e.getMessage().startsWith("x is not the correct password")) { throw e; } @@ -89,11 +89,11 @@ public class TestDriverAdapterCPDS { @Test public void testSimple() throws Exception { - Connection conn = pcds.getPooledConnection().getConnection(); + final Connection conn = pcds.getPooledConnection().getConnection(); assertNotNull(conn); - PreparedStatement stmt = conn.prepareStatement("select * from dual"); + final PreparedStatement stmt = conn.prepareStatement("select * from dual"); assertNotNull(stmt); - ResultSet rset = stmt.executeQuery(); + final ResultSet rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); rset.close(); @@ -103,11 +103,11 @@ public class TestDriverAdapterCPDS { @Test public void testSimpleWithUsername() throws Exception { - Connection conn = pcds.getPooledConnection("u1", "p1").getConnection(); + final Connection conn = pcds.getPooledConnection("u1", "p1").getConnection(); assertNotNull(conn); - PreparedStatement stmt = conn.prepareStatement("select * from dual"); + final PreparedStatement stmt = conn.prepareStatement("select * from dual"); assertNotNull(stmt); - ResultSet rset = stmt.executeQuery(); + final ResultSet rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); rset.close(); @@ -118,7 +118,7 @@ public class TestDriverAdapterCPDS { @Test public void testClosingWithUserName() throws Exception { - Connection[] c = new Connection[10]; + final Connection[] c = new Connection[10]; for (int i=0; i<c.length; i++) { c[i] = pcds.getPooledConnection("u1", "p1").getConnection(); } @@ -129,7 +129,7 @@ public class TestDriverAdapterCPDS { // get a new connection c[0] = pcds.getPooledConnection("u1", "p1").getConnection(); - for (Connection element : c) { + for (final Connection element : c) { element.close(); } @@ -137,7 +137,7 @@ public class TestDriverAdapterCPDS { for (int i=0; i<c.length; i++) { c[i] = pcds.getPooledConnection("u1", "p1").getConnection(); } - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -148,7 +148,7 @@ public class TestDriverAdapterCPDS { pcds.setUser("bad"); // Supply correct value in connection properties // This will overwrite field value - Properties properties = new Properties(); + final Properties properties = new Properties(); properties.put("user", "foo"); pcds.setConnectionProperties(properties); pcds.getPooledConnection().close(); @@ -179,13 +179,13 @@ public class TestDriverAdapterCPDS { // https://issues.apache.org/jira/browse/DBCP-376 @Test public void testDbcp367() throws Exception { - ThreadDbcp367[] threads = new ThreadDbcp367[200]; + final ThreadDbcp367[] threads = new ThreadDbcp367[200]; pcds.setPoolPreparedStatements(true); pcds.setMaxPreparedStatements(-1); pcds.setAccessToUnderlyingConnectionAllowed(true); - SharedPoolDataSource spds = new SharedPoolDataSource(); + final SharedPoolDataSource spds = new SharedPoolDataSource(); spds.setConnectionPoolDataSource(pcds); spds.setMaxTotal(threads.length + 10); spds.setDefaultMaxWaitMillis(-1); @@ -228,7 +228,7 @@ public class TestDriverAdapterCPDS { c = ds.getConnection(); c.close(); } - } catch (SQLException sqle) { + } catch (final SQLException sqle) { failed = true; sqle.printStackTrace(); }
Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/ConnectionPoolDataSourceProxy.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/ConnectionPoolDataSourceProxy.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/ConnectionPoolDataSourceProxy.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/ConnectionPoolDataSourceProxy.java Mon Feb 8 21:56:48 2016 @@ -89,7 +89,7 @@ public class ConnectionPoolDataSourcePro * Create a TesterPooledConnection with notifyOnClose turned on */ protected PooledConnection wrapPooledConnection(PooledConnection pc) { - PooledConnectionProxy tpc = new PooledConnectionProxy(pc); + final PooledConnectionProxy tpc = new PooledConnectionProxy(pc); tpc.setNotifyOnClose(true); return tpc; } Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/PooledConnectionProxy.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/PooledConnectionProxy.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/PooledConnectionProxy.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/PooledConnectionProxy.java Mon Feb 8 21:56:48 2016 @@ -100,9 +100,9 @@ public class PooledConnectionProxy imple * sends a connectionClosed event to listeners. */ void notifyListeners() { - ConnectionEvent event = new ConnectionEvent(this); - Object[] listeners = eventListeners.toArray(); - for (Object listener : listeners) { + final ConnectionEvent event = new ConnectionEvent(this); + final Object[] listeners = eventListeners.toArray(); + for (final Object listener : listeners) { ((ConnectionEventListener) listener).connectionClosed(event); } } @@ -139,8 +139,8 @@ public class PooledConnectionProxy imple */ @Override public void connectionErrorOccurred(ConnectionEvent event) { - Object[] listeners = eventListeners.toArray(); - for (Object listener : listeners) { + final Object[] listeners = eventListeners.toArray(); + for (final Object listener : listeners) { ((ConnectionEventListener) listener).connectionErrorOccurred(event); } } @@ -149,7 +149,7 @@ public class PooledConnectionProxy imple * Generate a connection error event */ public void throwConnectionError() { - ConnectionEvent event = new ConnectionEvent(this); + final ConnectionEvent event = new ConnectionEvent(this); connectionErrorOccurred(event); } 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=1729274&r1=1729273&r2=1729274&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 8 21:56:48 2016 @@ -41,7 +41,7 @@ public class TestCPDSConnectionFactory { @Before public void setUp() throws Exception { cpds = new ConnectionPoolDataSourceProxy(new DriverAdapterCPDS()); - DriverAdapterCPDS delegate = (DriverAdapterCPDS) cpds.getDelegate(); + final DriverAdapterCPDS delegate = (DriverAdapterCPDS) cpds.getDelegate(); delegate.setDriver("org.apache.commons.dbcp2.TesterDriver"); delegate.setUrl("jdbc:apache:commons:testdriver"); delegate.setUser("username"); @@ -57,14 +57,14 @@ public class TestCPDSConnectionFactory { */ @Test public void testSharedPoolDSDestroyOnReturn() throws Exception { - PerUserPoolDataSource ds = new PerUserPoolDataSource(); + final PerUserPoolDataSource ds = new PerUserPoolDataSource(); ds.setConnectionPoolDataSource(cpds); ds.setPerUserMaxTotal("username", Integer.valueOf(10)); ds.setPerUserMaxWaitMillis("username", Long.valueOf(50)); ds.setPerUserMaxIdle("username", Integer.valueOf(2)); - Connection conn1 = ds.getConnection("username", "password"); - Connection conn2 = ds.getConnection("username", "password"); - Connection conn3 = ds.getConnection("username", "password"); + final Connection conn1 = ds.getConnection("username", "password"); + final Connection conn2 = ds.getConnection("username", "password"); + final Connection conn3 = ds.getConnection("username", "password"); assertEquals(3, ds.getNumActive("username")); conn1.close(); assertEquals(1, ds.getNumIdle("username")); @@ -84,21 +84,21 @@ public class TestCPDSConnectionFactory { @Test public void testConnectionErrorCleanup() throws Exception { // Setup factory - CPDSConnectionFactory factory = new CPDSConnectionFactory( + final CPDSConnectionFactory factory = new CPDSConnectionFactory( cpds, null, -1, false, "username", "password"); - GenericObjectPool<PooledConnectionAndInfo> pool = + final GenericObjectPool<PooledConnectionAndInfo> pool = new GenericObjectPool<>(factory); factory.setPool(pool); // Checkout a pair of connections - PooledConnection pcon1 = pool.borrowObject().getPooledConnection(); - Connection con1 = pcon1.getConnection(); - PooledConnection pcon2 = pool.borrowObject().getPooledConnection(); + final PooledConnection pcon1 = pool.borrowObject().getPooledConnection(); + final Connection con1 = pcon1.getConnection(); + final PooledConnection pcon2 = pool.borrowObject().getPooledConnection(); assertEquals(2, pool.getNumActive()); assertEquals(0, pool.getNumIdle()); // Verify listening - PooledConnectionProxy pc = (PooledConnectionProxy) pcon1; + final PooledConnectionProxy pc = (PooledConnectionProxy) pcon1; assertTrue(pc.getListeners().contains(factory)); // Throw connectionError event @@ -114,7 +114,7 @@ public class TestCPDSConnectionFactory { assertEquals(0, pool.getNumIdle()); // Ask for another connection - PooledConnection pcon3 = pool.borrowObject().getPooledConnection(); + final PooledConnection pcon3 = pool.borrowObject().getPooledConnection(); assertTrue(!pcon3.equals(pcon1)); // better not get baddie back assertTrue(!pc.getListeners().contains(factory)); // verify cleanup assertEquals(2, pool.getNumActive()); @@ -130,7 +130,7 @@ public class TestCPDSConnectionFactory { try { pc.getConnection(); fail("Expecting SQLException using closed PooledConnection"); - } catch (SQLException ex) { + } catch (final SQLException ex) { // expected } @@ -149,13 +149,13 @@ public class TestCPDSConnectionFactory { */ @Test public void testNullValidationQuery() throws Exception { - CPDSConnectionFactory factory = + final CPDSConnectionFactory factory = new CPDSConnectionFactory(cpds, null, -1, false, "username", "password"); - GenericObjectPool<PooledConnectionAndInfo> pool = new GenericObjectPool<>(factory); + final GenericObjectPool<PooledConnectionAndInfo> pool = new GenericObjectPool<>(factory); factory.setPool(pool); pool.setTestOnBorrow(true); - PooledConnection pcon = pool.borrowObject().getPooledConnection(); - Connection con = pcon.getConnection(); + final PooledConnection pcon = pool.borrowObject().getPooledConnection(); + final Connection con = pcon.getConnection(); con.close(); } Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestFactory.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestFactory.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestFactory.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestFactory.java Mon Feb 8 21:56:48 2016 @@ -43,19 +43,19 @@ public class TestFactory { // http://issues.apache.org/bugzilla/show_bug.cgi?id=24082 @Test public void testJNDI2Pools() throws Exception { - Reference refObj = new Reference(SharedPoolDataSource.class.getName()); + final Reference refObj = new Reference(SharedPoolDataSource.class.getName()); refObj.add(new StringRefAddr("dataSourceName","java:comp/env/jdbc/bookstoreCPDS")); - Context context = new InitialContext(); - Hashtable<?, ?> env = new Hashtable<>(); + final Context context = new InitialContext(); + final Hashtable<?, ?> env = new Hashtable<>(); - ObjectFactory factory = new SharedPoolDataSourceFactory(); + final ObjectFactory factory = new SharedPoolDataSourceFactory(); - Name name = new CompositeName("myDB"); - Object obj = factory.getObjectInstance(refObj, name, context, env); + final Name name = new CompositeName("myDB"); + final Object obj = factory.getObjectInstance(refObj, name, context, env); assertNotNull(obj); - Name name2 = new CompositeName("myDB2"); - Object obj2 = factory.getObjectInstance(refObj, name2, context, env); + final Name name2 = new CompositeName("myDB2"); + final Object obj2 = factory.getObjectInstance(refObj, name2, context, env); assertNotNull(obj2); } } Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestInstanceKeyDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestInstanceKeyDataSource.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestInstanceKeyDataSource.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestInstanceKeyDataSource.java Mon Feb 8 21:56:48 2016 @@ -45,13 +45,13 @@ public class TestInstanceKeyDataSource { pcds.setUser("foo"); pcds.setPassword("bar"); pcds.setPoolPreparedStatements(false); - ThrowOnSetupDefaultsDataSource tds = new ThrowOnSetupDefaultsDataSource(); + final ThrowOnSetupDefaultsDataSource tds = new ThrowOnSetupDefaultsDataSource(); tds.setConnectionPoolDataSource(pcds); - int numConnections = tds.getNumActive(); + final int numConnections = tds.getNumActive(); try { tds.getConnection("foo", "bar"); fail("Expecting SQLException"); - } catch (SQLException ex) { + } catch (final SQLException ex) { //Expected } assertEquals(numConnections,tds.getNumActive()); 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=1729274&r1=1729273&r2=1729274&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 8 21:56:48 2016 @@ -42,7 +42,7 @@ public class TestKeyedCPDSConnectionFact @Before public void setUp() throws Exception { cpds = new ConnectionPoolDataSourceProxy(new DriverAdapterCPDS()); - DriverAdapterCPDS delegate = (DriverAdapterCPDS) cpds.getDelegate(); + final DriverAdapterCPDS delegate = (DriverAdapterCPDS) cpds.getDelegate(); delegate.setDriver("org.apache.commons.dbcp2.TesterDriver"); delegate.setUrl("jdbc:apache:commons:testdriver"); delegate.setUser("username"); @@ -58,14 +58,14 @@ public class TestKeyedCPDSConnectionFact */ @Test public void testSharedPoolDSDestroyOnReturn() throws Exception { - SharedPoolDataSource ds = new SharedPoolDataSource(); + final SharedPoolDataSource ds = new SharedPoolDataSource(); ds.setConnectionPoolDataSource(cpds); ds.setMaxTotal(10); ds.setDefaultMaxWaitMillis(50); ds.setDefaultMaxIdle(2); - Connection conn1 = ds.getConnection("username", "password"); - Connection conn2 = ds.getConnection("username", "password"); - Connection conn3 = ds.getConnection("username", "password"); + final Connection conn1 = ds.getConnection("username", "password"); + final Connection conn2 = ds.getConnection("username", "password"); + final Connection conn3 = ds.getConnection("username", "password"); assertEquals(3, ds.getNumActive()); conn1.close(); assertEquals(1, ds.getNumIdle()); @@ -85,25 +85,25 @@ public class TestKeyedCPDSConnectionFact @Test public void testConnectionErrorCleanup() throws Exception { // Setup factory - UserPassKey key = new UserPassKey("username", "password"); - KeyedCPDSConnectionFactory factory = + final UserPassKey key = new UserPassKey("username", "password"); + final KeyedCPDSConnectionFactory factory = new KeyedCPDSConnectionFactory(cpds, null, -1, false); - KeyedObjectPool<UserPassKey, PooledConnectionAndInfo> pool = new GenericKeyedObjectPool<>(factory); + final KeyedObjectPool<UserPassKey, PooledConnectionAndInfo> pool = new GenericKeyedObjectPool<>(factory); factory.setPool(pool); // Checkout a pair of connections - PooledConnection pcon1 = + final PooledConnection pcon1 = pool.borrowObject(key) .getPooledConnection(); - Connection con1 = pcon1.getConnection(); - PooledConnection pcon2 = + final Connection con1 = pcon1.getConnection(); + final PooledConnection pcon2 = pool.borrowObject(key) .getPooledConnection(); assertEquals(2, pool.getNumActive(key)); assertEquals(0, pool.getNumIdle(key)); // Verify listening - PooledConnectionProxy pc = (PooledConnectionProxy) pcon1; + final PooledConnectionProxy pc = (PooledConnectionProxy) pcon1; assertTrue(pc.getListeners().contains(factory)); // Throw connectionError event @@ -120,7 +120,7 @@ public class TestKeyedCPDSConnectionFact // Ask for another connection - should trigger makeObject, which causes // cleanup, removing listeners. - PooledConnection pcon3 = + final PooledConnection pcon3 = pool.borrowObject(key) .getPooledConnection(); assertTrue(!pcon3.equals(pcon1)); // better not get baddie back @@ -138,7 +138,7 @@ public class TestKeyedCPDSConnectionFact try { pc.getConnection(); fail("Expecting SQLException using closed PooledConnection"); - } catch (SQLException ex) { + } catch (final SQLException ex) { // expected } @@ -157,14 +157,14 @@ public class TestKeyedCPDSConnectionFact */ @Test public void testNullValidationQuery() throws Exception { - UserPassKey key = new UserPassKey("username", "password"); - KeyedCPDSConnectionFactory factory = + final UserPassKey key = new UserPassKey("username", "password"); + final KeyedCPDSConnectionFactory factory = new KeyedCPDSConnectionFactory(cpds, null, -1, false); - GenericKeyedObjectPool<UserPassKey, PooledConnectionAndInfo> pool = new GenericKeyedObjectPool<>(factory); + final GenericKeyedObjectPool<UserPassKey, PooledConnectionAndInfo> pool = new GenericKeyedObjectPool<>(factory); factory.setPool(pool); pool.setTestOnBorrow(true); - PooledConnection pcon = pool.borrowObject(key).getPooledConnection(); - Connection con = pcon.getConnection(); + final PooledConnection pcon = pool.borrowObject(key).getPooledConnection(); + final Connection con = pcon.getConnection(); con.close(); } } Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java Mon Feb 8 21:56:48 2016 @@ -56,14 +56,14 @@ public class TestPerUserPoolDataSource e @Before public void setUp() throws Exception { - DriverAdapterCPDS pcds = new DriverAdapterCPDS(); + final DriverAdapterCPDS pcds = new DriverAdapterCPDS(); pcds.setDriver("org.apache.commons.dbcp2.TesterDriver"); pcds.setUrl("jdbc:apache:commons:testdriver"); pcds.setUser("foo"); pcds.setPassword("bar"); pcds.setAccessToUnderlyingConnectionAllowed(true); - PerUserPoolDataSource tds = new PerUserPoolDataSource(); + final PerUserPoolDataSource tds = new PerUserPoolDataSource(); tds.setConnectionPoolDataSource(pcds); tds.setDefaultMaxTotal(getMaxTotal()); tds.setDefaultMaxWaitMillis((int)getMaxWaitMillis()); @@ -85,7 +85,7 @@ public class TestPerUserPoolDataSource e // Use bad password try (Connection c = ds.getConnection("u1", "zlsafjk");){ fail("Able to retrieve connection with incorrect password"); - } catch (SQLException e1) { + } catch (final SQLException e1) { // should fail } @@ -94,7 +94,7 @@ public class TestPerUserPoolDataSource e ds.getConnection("u1", "p1").close(); try (Connection c = ds.getConnection("u1", "x")){ fail("Able to retrieve connection with incorrect password"); - } catch (SQLException e) { + } catch (final SQLException e) { if (!e.getMessage().startsWith("Given password did not match")) { throw e; } @@ -108,11 +108,11 @@ public class TestPerUserPoolDataSource e ds.getConnection("foo", "bar").close(); try (Connection c = ds.getConnection("foob", "ar")) { fail("Should have caused an SQLException"); - } catch (SQLException expected) { + } catch (final SQLException expected) { } try (Connection c = ds.getConnection("foo", "baz")){ fail("Should have generated SQLException"); - } catch (SQLException expected) { + } catch (final SQLException expected) { } } @@ -120,11 +120,11 @@ public class TestPerUserPoolDataSource e @Test public void testSimple() throws Exception { - Connection conn = ds.getConnection(); + final Connection conn = ds.getConnection(); assertNotNull(conn); - PreparedStatement stmt = conn.prepareStatement("select * from dual"); + final PreparedStatement stmt = conn.prepareStatement("select * from dual"); assertNotNull(stmt); - ResultSet rset = stmt.executeQuery(); + final ResultSet rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); rset.close(); @@ -135,11 +135,11 @@ public class TestPerUserPoolDataSource e @Test public void testSimpleWithUsername() throws Exception { - Connection conn = ds.getConnection("u1", "p1"); + final Connection conn = ds.getConnection("u1", "p1"); assertNotNull(conn); - PreparedStatement stmt = conn.prepareStatement("select * from dual"); + final PreparedStatement stmt = conn.prepareStatement("select * from dual"); assertNotNull(stmt); - ResultSet rset = stmt.executeQuery(); + final ResultSet rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); rset.close(); @@ -151,7 +151,7 @@ public class TestPerUserPoolDataSource e public void testClosingWithUserName() throws Exception { - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; // open the maximum connections for (int i=0; i<c.length; i++) { @@ -164,7 +164,7 @@ public class TestPerUserPoolDataSource e // get a new connection c[0] = ds.getConnection("u1", "p1"); - for (Connection element : c) { + for (final Connection element : c) { element.close(); } @@ -173,7 +173,7 @@ public class TestPerUserPoolDataSource e { c[i] = ds.getConnection("u1", "p1"); } - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -206,7 +206,7 @@ public class TestPerUserPoolDataSource e conn.close(); try (Statement s = conn.createStatement()){ fail("Can't use closed connections"); - } catch(SQLException e) { + } catch(final SQLException e) { // expected } @@ -238,7 +238,7 @@ public class TestPerUserPoolDataSource e public void testOpening() throws Exception { - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; // test that opening new connections is not closing previous for (int i=0; i<c.length; i++) { @@ -250,7 +250,7 @@ public class TestPerUserPoolDataSource e } } - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -260,7 +260,7 @@ public class TestPerUserPoolDataSource e public void testClosing() throws Exception { - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; // open the maximum connections for (int i=0; i<c.length; i++) { @@ -274,7 +274,7 @@ public class TestPerUserPoolDataSource e // get a new connection c[0] = ds.getConnection(); - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -282,7 +282,7 @@ public class TestPerUserPoolDataSource e @Override @Test public void testMaxTotal() throws Exception { - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; for (int i=0; i<c.length; i++) { c[i] = ds.getConnection(); assertTrue(c[i] != null); @@ -290,12 +290,12 @@ public class TestPerUserPoolDataSource e try (Connection conn = ds.getConnection()){ fail("Allowed to open more than DefaultMaxTotal connections."); - } catch(java.sql.SQLException e) { + } catch(final java.sql.SQLException e) { // should only be able to open 10 connections, so this test should // throw an exception } - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -306,13 +306,13 @@ public class TestPerUserPoolDataSource e */ @Test public void testMaxWaitMillisZero() throws Exception { - PerUserPoolDataSource tds = (PerUserPoolDataSource) ds; + final PerUserPoolDataSource tds = (PerUserPoolDataSource) ds; tds.setDefaultMaxWaitMillis(0); tds.setPerUserMaxTotal("u1", Integer.valueOf(1)); - Connection conn = tds.getConnection("u1", "p1"); + final Connection conn = tds.getConnection("u1", "p1"); try (Connection c2 = tds.getConnection("u1", "p1")){ fail("Expecting Pool Exhausted exception"); - } catch (SQLException ex) { + } catch (final SQLException ex) { // expected } conn.close(); @@ -320,7 +320,7 @@ public class TestPerUserPoolDataSource e @Test public void testPerUserMethods() throws Exception { - PerUserPoolDataSource tds = (PerUserPoolDataSource) ds; + final PerUserPoolDataSource tds = (PerUserPoolDataSource) ds; // you need to set per user maxTotal otherwise there is no accounting tds.setPerUserMaxTotal("u1", Integer.valueOf(5)); @@ -388,18 +388,18 @@ public class TestPerUserPoolDataSource e @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(); @@ -409,19 +409,19 @@ public class TestPerUserPoolDataSource e @Test public void testSerialization() throws Exception { // make sure the pool has initialized - Connection conn = ds.getConnection(); + final Connection conn = ds.getConnection(); conn.close(); // serialize - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(baos); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream out = new ObjectOutputStream(baos); out.writeObject(ds); - byte[] b = baos.toByteArray(); + final byte[] b = baos.toByteArray(); out.close(); - ByteArrayInputStream bais = new ByteArrayInputStream(b); - ObjectInputStream in = new ObjectInputStream(bais); - Object obj = in.readObject(); + final ByteArrayInputStream bais = new ByteArrayInputStream(b); + final ObjectInputStream in = new ObjectInputStream(bais); + final Object obj = in.readObject(); in.close(); assertEquals( 1, ((PerUserPoolDataSource)obj).getNumIdle() ); @@ -431,7 +431,7 @@ public class TestPerUserPoolDataSource e // unregistered user is in the same pool as without username @Test public void testUnregisteredUser() throws Exception { - PerUserPoolDataSource tds = (PerUserPoolDataSource) ds; + final PerUserPoolDataSource tds = (PerUserPoolDataSource) ds; assertEquals(0, tds.getNumActive()); assertEquals(0, tds.getNumIdle()); @@ -466,11 +466,11 @@ public class TestPerUserPoolDataSource e TesterDriver.addUser("hanafey", "password"); TesterDriver.addUser("jsmith", "password"); - PerUserPoolDataSource puds = (PerUserPoolDataSource) ds; + final PerUserPoolDataSource puds = (PerUserPoolDataSource) ds; puds.setPerUserMaxTotal("jsmith", Integer.valueOf(2)); - String[] users = {"mkh", "hanafey", "jsmith"}; - String password = "password"; - Connection[] c = new Connection[users.length]; + final String[] users = {"mkh", "hanafey", "jsmith"}; + final String password = "password"; + final Connection[] c = new Connection[users.length]; for (int i = 0; i < users.length; i++) { c[i] = puds.getConnection(users[i], password); assertEquals(users[i], getUsername(c[i])); @@ -487,11 +487,11 @@ public class TestPerUserPoolDataSource e TesterDriver.addUser("hanafey", "password"); TesterDriver.addUser("jsmith", "password"); - PerUserPoolDataSource puds = (PerUserPoolDataSource) ds; + final PerUserPoolDataSource puds = (PerUserPoolDataSource) ds; puds.setPerUserMaxTotal("jsmith", Integer.valueOf(2)); - String[] users = {"jsmith", "hanafey", "mkh"}; - String password = "password"; - Connection[] c = new Connection[users.length]; + final String[] users = {"jsmith", "hanafey", "mkh"}; + final String password = "password"; + final Connection[] c = new Connection[users.length]; for (int i = 0; i < users.length; i++) { c[i] = puds.getConnection(users[i], password); assertEquals(users[i], getUsername(c[i])); @@ -506,16 +506,16 @@ public class TestPerUserPoolDataSource e public void testChangePassword() throws Exception { try (Connection c = ds.getConnection("foo", "bay")){ fail("Should have generated SQLException"); - } catch (SQLException expected) { + } catch (final SQLException expected) { } - Connection con1 = ds.getConnection("foo", "bar"); - Connection con2 = ds.getConnection("foo", "bar"); - Connection con3 = ds.getConnection("foo", "bar"); + final Connection con1 = ds.getConnection("foo", "bar"); + final Connection con2 = ds.getConnection("foo", "bar"); + final Connection con3 = ds.getConnection("foo", "bar"); con1.close(); con2.close(); TesterDriver.addUser("foo","bay"); // change the user/password setting try { - Connection con4 = ds.getConnection("foo", "bay"); // new password + final Connection con4 = ds.getConnection("foo", "bay"); // new password // Idle instances with old password should have been cleared assertEquals("Should be no idle connections in the pool", 0, ((PerUserPoolDataSource) ds).getNumIdle("foo")); @@ -525,9 +525,9 @@ public class TestPerUserPoolDataSource e 1, ((PerUserPoolDataSource) ds).getNumIdle("foo")); try (Connection c = ds.getConnection("foo", "bar")) { // old password fail("Should have generated SQLException"); - } catch (SQLException expected) { + } catch (final SQLException expected) { } - Connection con5 = ds.getConnection("foo", "bay"); // take the idle one + final Connection con5 = ds.getConnection("foo", "bay"); // take the idle one con3.close(); // Return a connection with the old password ds.getConnection("foo", "bay").close(); // will try bad returned connection and destroy it assertEquals("Should be one idle connection in the pool", Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java Mon Feb 8 21:56:48 2016 @@ -63,7 +63,7 @@ public class TestSharedPoolDataSource ex pcds.setPoolPreparedStatements(false); pcds.setAccessToUnderlyingConnectionAllowed(true); - SharedPoolDataSource tds = new SharedPoolDataSource(); + final SharedPoolDataSource tds = new SharedPoolDataSource(); tds.setConnectionPoolDataSource(pcds); tds.setMaxTotal(getMaxTotal()); tds.setDefaultMaxWaitMillis((int)getMaxWaitMillis()); @@ -86,7 +86,7 @@ public class TestSharedPoolDataSource ex ds.getConnection("u2", "p2").close(); try (Connection c = ds.getConnection("u1", "zlsafjk")){ // Use bad password fail("Able to retrieve connection with incorrect password"); - } catch (SQLException e1) { + } catch (final SQLException e1) { // should fail } @@ -94,7 +94,7 @@ public class TestSharedPoolDataSource ex ds.getConnection("u1", "p1").close(); try (Connection c = ds.getConnection("u1", "x")) { fail("Able to retrieve connection with incorrect password"); - } catch (SQLException e) { + } catch (final SQLException e) { if (!e.getMessage().startsWith("Given password did not match")) { throw e; } @@ -108,11 +108,11 @@ public class TestSharedPoolDataSource ex ds.getConnection("foo", "bar").close(); try (Connection c = ds.getConnection("u1", "ar")) { fail("Should have caused an SQLException"); - } catch (SQLException expected) { + } catch (final SQLException expected) { } try (Connection c = ds.getConnection("u1", "baz")) { fail("Should have generated SQLException"); - } catch (SQLException expected) { + } catch (final SQLException expected) { } } @@ -121,11 +121,11 @@ public class TestSharedPoolDataSource ex @Test public void testSimple() throws Exception { - Connection conn = ds.getConnection(); + final Connection conn = ds.getConnection(); assertNotNull(conn); - PreparedStatement stmt = conn.prepareStatement("select * from dual"); + final PreparedStatement stmt = conn.prepareStatement("select * from dual"); assertNotNull(stmt); - ResultSet rset = stmt.executeQuery(); + final ResultSet rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); rset.close(); @@ -136,11 +136,11 @@ public class TestSharedPoolDataSource ex @Test public void testSimpleWithUsername() throws Exception { - Connection conn = ds.getConnection("u1", "p1"); + final Connection conn = ds.getConnection("u1", "p1"); assertNotNull(conn); - PreparedStatement stmt = conn.prepareStatement("select * from dual"); + final PreparedStatement stmt = conn.prepareStatement("select * from dual"); assertNotNull(stmt); - ResultSet rset = stmt.executeQuery(); + final ResultSet rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); rset.close(); @@ -152,7 +152,7 @@ public class TestSharedPoolDataSource ex public void testClosingWithUserName() throws Exception { - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; // open the maximum connections for (int i=0; i<c.length; i++) { @@ -165,7 +165,7 @@ public class TestSharedPoolDataSource ex // get a new connection c[0] = ds.getConnection("u1", "p1"); - for (Connection element : c) { + for (final Connection element : c) { element.close(); } @@ -174,7 +174,7 @@ public class TestSharedPoolDataSource ex { c[i] = ds.getConnection("u1", "p1"); } - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -207,7 +207,7 @@ public class TestSharedPoolDataSource ex conn.close(); try (Statement s = conn.createStatement()){ fail("Can't use closed connections"); - } catch(SQLException e) { + } catch(final SQLException e) { // expected } @@ -239,7 +239,7 @@ public class TestSharedPoolDataSource ex public void testOpening() throws Exception { - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; // test that opening new connections is not closing previous for (int i=0; i<c.length; i++) { @@ -251,7 +251,7 @@ public class TestSharedPoolDataSource ex } } - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -261,7 +261,7 @@ public class TestSharedPoolDataSource ex public void testClosing() throws Exception { - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; // open the maximum connections for (int i=0; i<c.length; i++) { @@ -275,7 +275,7 @@ public class TestSharedPoolDataSource ex // get a new connection c[0] = ds.getConnection(); - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -288,7 +288,7 @@ public class TestSharedPoolDataSource ex @Test public void testClosePool() throws Exception { ((SharedPoolDataSource)ds).close(); - SharedPoolDataSource tds = new SharedPoolDataSource(); + final SharedPoolDataSource tds = new SharedPoolDataSource(); // NPE before BZ 37359 fix tds.close(); } @@ -296,7 +296,7 @@ public class TestSharedPoolDataSource ex @Override @Test public void testMaxTotal() throws Exception { - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; for (int i=0; i<c.length; i++) { c[i] = ds.getConnection(); assertTrue(c[i] != null); @@ -304,12 +304,12 @@ public class TestSharedPoolDataSource ex try (Connection conn = ds.getConnection()){ fail("Allowed to open more than DefaultMaxTotal connections."); - } catch(java.sql.SQLException e) { + } catch(final java.sql.SQLException e) { // should only be able to open 10 connections, so this test should // throw an exception } - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -321,18 +321,18 @@ public class TestSharedPoolDataSource ex ((SharedPoolDataSource)ds).setDefaultMaxWaitMillis(maxWaitMillis); // Obtain all the connections from the pool - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; for (int i=0; i<c.length; i++) { c[i] = ds.getConnection("foo","bar"); assertTrue(c[i] != null); } - long start = System.currentTimeMillis(); + final long start = System.currentTimeMillis(); // Run a thread test with minimal hold time // All threads should end after maxWaitMillis - DBCP-291 final PoolTest[] pts = new PoolTest[theadCount]; - ThreadGroup threadGroup = new ThreadGroup("testMaxWaitMillis"); + final ThreadGroup threadGroup = new ThreadGroup("testMaxWaitMillis"); // Should take ~maxWaitMillis for threads to stop for (int i = 0; i < pts.length; i++) { @@ -345,7 +345,7 @@ public class TestSharedPoolDataSource ex } - long end = System.currentTimeMillis(); + final long end = System.currentTimeMillis(); System.out.println("testMaxWaitMillis took " + (end-start) + " ms. maxWaitMillis: "+maxWaitMillis); @@ -354,7 +354,7 @@ public class TestSharedPoolDataSource ex assertTrue(end-start < 2 * maxWaitMillis); // Put all the connections back in the pool - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -377,18 +377,18 @@ public class TestSharedPoolDataSource ex @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(); @@ -402,11 +402,11 @@ public class TestSharedPoolDataSource ex { pcds.setPoolPreparedStatements(true); - Connection conn = ds.getConnection(); + final Connection conn = ds.getConnection(); assertNotNull(conn); - PreparedStatement stmt = conn.prepareStatement("select * from dual"); + final PreparedStatement stmt = conn.prepareStatement("select * from dual"); assertNotNull(stmt); - ResultSet rset = stmt.executeQuery(); + final ResultSet rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); rset.close(); @@ -461,7 +461,7 @@ public class TestSharedPoolDataSource ex } private void doTestPoolPreparedStatements(PrepareStatementCallback callBack) throws Exception { - DriverAdapterCPDS mypcds = new DriverAdapterCPDS(); + final DriverAdapterCPDS mypcds = new DriverAdapterCPDS(); DataSource myds = null; mypcds.setDriver("org.apache.commons.dbcp2.TesterDriver"); mypcds.setUrl("jdbc:apache:commons:testdriver"); @@ -470,7 +470,7 @@ public class TestSharedPoolDataSource ex mypcds.setPoolPreparedStatements(true); mypcds.setMaxPreparedStatements(10); - SharedPoolDataSource tds = new SharedPoolDataSource(); + final SharedPoolDataSource tds = new SharedPoolDataSource(); tds.setConnectionPoolDataSource(mypcds); tds.setMaxTotal(getMaxTotal()); tds.setDefaultMaxWaitMillis((int)getMaxWaitMillis()); @@ -488,7 +488,7 @@ public class TestSharedPoolDataSource ex stmt = callBack.getPreparedStatement(); assertNotNull(stmt); - long l1HashCode = ((DelegatingStatement) stmt).getDelegate().hashCode(); + final long l1HashCode = ((DelegatingStatement) stmt).getDelegate().hashCode(); rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); @@ -497,7 +497,7 @@ public class TestSharedPoolDataSource ex stmt = callBack.getPreparedStatement(); assertNotNull(stmt); - long l2HashCode = ((DelegatingStatement) stmt).getDelegate().hashCode(); + final long l2HashCode = ((DelegatingStatement) stmt).getDelegate().hashCode(); rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); @@ -514,7 +514,7 @@ public class TestSharedPoolDataSource ex stmt = callBack.getPreparedStatement(); assertNotNull(stmt); - long l3HashCode = ((DelegatingStatement) stmt).getDelegate().hashCode(); + final long l3HashCode = ((DelegatingStatement) stmt).getDelegate().hashCode(); rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); @@ -523,7 +523,7 @@ public class TestSharedPoolDataSource ex stmt = callBack.getPreparedStatement(); assertNotNull(stmt); - long l4HashCode = ((DelegatingStatement) stmt).getDelegate().hashCode(); + final long l4HashCode = ((DelegatingStatement) stmt).getDelegate().hashCode(); rset = stmt.executeQuery(); assertNotNull(rset); assertTrue(rset.next()); @@ -552,11 +552,11 @@ public class TestSharedPoolDataSource ex public void testChangePassword() throws Exception { try (Connection c = ds.getConnection("foo", "bay")){ fail("Should have generated SQLException"); - } catch (SQLException expected) { + } catch (final SQLException expected) { } - Connection con1 = ds.getConnection("foo", "bar"); - Connection con2 = ds.getConnection("foo", "bar"); - Connection con3 = ds.getConnection("foo", "bar"); + final Connection con1 = ds.getConnection("foo", "bar"); + final Connection con2 = ds.getConnection("foo", "bar"); + final Connection con3 = ds.getConnection("foo", "bar"); con1.close(); con2.close(); TesterDriver.addUser("foo","bay"); // change the user/password setting @@ -570,9 +570,9 @@ public class TestSharedPoolDataSource ex 1, ((SharedPoolDataSource) ds).getNumIdle()); try (Connection con4b = ds.getConnection("foo", "bar")) { // old password fail("Should have generated SQLException"); - } catch (SQLException expected) { + } catch (final SQLException expected) { } - Connection con5 = ds.getConnection("foo", "bay"); // take the idle one + final Connection con5 = ds.getConnection("foo", "bay"); // take the idle one con3.close(); // Return a connection with the old password ds.getConnection("foo", "bay").close(); // will try bad returned connection and destroy it assertEquals("Should be one idle connection in the pool", @@ -587,26 +587,26 @@ public class TestSharedPoolDataSource ex public void testDbcp369() { final ArrayList<SharedPoolDataSource> dataSources = new ArrayList<>(); for (int j = 0; j < 10000; j++) { - SharedPoolDataSource dataSource = new SharedPoolDataSource(); + final SharedPoolDataSource dataSource = new SharedPoolDataSource(); dataSources.add(dataSource); } - Thread t1 = new Thread(new Runnable() { + final Thread t1 = new Thread(new Runnable() { @Override public void run() { - for (SharedPoolDataSource dataSource : dataSources) { + for (final SharedPoolDataSource dataSource : dataSources) { dataSource.setDataSourceName("a"); } } }); - Thread t2 = new Thread(new Runnable() { + final Thread t2 = new Thread(new Runnable() { @Override public void run() { - for (SharedPoolDataSource dataSource : dataSources) { + for (final SharedPoolDataSource dataSource : dataSources) { try { dataSource.close(); - } catch (Exception e) { + } catch (final Exception e) { // Ignore } } @@ -619,7 +619,7 @@ public class TestSharedPoolDataSource ex try { t1.join(); t2.join(); - } catch (InterruptedException ie) { + } catch (final InterruptedException ie) { // Ignore } } Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java Mon Feb 8 21:56:48 2016 @@ -34,7 +34,7 @@ public class TestBasicManagedDataSource @Override protected BasicDataSource createDataSource() throws Exception { - BasicManagedDataSource basicManagedDataSource = new BasicManagedDataSource(); + final BasicManagedDataSource basicManagedDataSource = new BasicManagedDataSource(); basicManagedDataSource.setTransactionManager(new TransactionManagerImpl()); return basicManagedDataSource; } @@ -46,7 +46,7 @@ public class TestBasicManagedDataSource */ @Test public void testReallyClose() throws Exception { - BasicManagedDataSource basicManagedDataSource = new BasicManagedDataSource(); + final BasicManagedDataSource basicManagedDataSource = new BasicManagedDataSource(); basicManagedDataSource.setTransactionManager(new TransactionManagerImpl()); basicManagedDataSource.setDriverClassName("org.apache.commons.dbcp2.TesterDriver"); basicManagedDataSource.setUrl("jdbc:apache:commons:testdriver"); @@ -54,15 +54,15 @@ public class TestBasicManagedDataSource basicManagedDataSource.setPassword("password"); basicManagedDataSource.setMaxIdle(1); // Create two connections - ManagedConnection<?> conn = (ManagedConnection<?>) basicManagedDataSource.getConnection(); + final ManagedConnection<?> conn = (ManagedConnection<?>) basicManagedDataSource.getConnection(); assertNotNull(basicManagedDataSource.getTransactionRegistry().getXAResource(conn)); - ManagedConnection<?> conn2 = (ManagedConnection<?>) basicManagedDataSource.getConnection(); + final ManagedConnection<?> conn2 = (ManagedConnection<?>) basicManagedDataSource.getConnection(); conn2.close(); // Return one connection to the pool conn.close(); // No room at the inn - this will trigger reallyClose(), which should unregister try { basicManagedDataSource.getTransactionRegistry().getXAResource(conn); fail("Expecting SQLException - XAResources orphaned"); - } catch (SQLException ex) { + } catch (final SQLException ex) { // expected } conn2.close(); Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java Mon Feb 8 21:56:48 2016 @@ -52,8 +52,8 @@ public class TestDataSourceXAConnectionF bmds = new BasicManagedDataSource(); bmds.setTransactionManager(new TransactionManagerImpl()); bmds.setXADataSource("notnull"); - XADataSourceHandle handle = new XADataSourceHandle(); - XADataSource xads = (XADataSource) Proxy.newProxyInstance( + final XADataSourceHandle handle = new XADataSourceHandle(); + final XADataSource xads = (XADataSource) Proxy.newProxyInstance( XADataSourceHandle.class.getClassLoader(), new Class[] { XADataSource.class }, handle); bmds.setXaDataSourceInstance(xads); @@ -68,7 +68,7 @@ public class TestDataSourceXAConnectionF @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - String methodName = method.getName(); + final String methodName = method.getName(); if (methodName.equals("hashCode")) { return Integer.valueOf(System.identityHashCode(proxy)); } @@ -81,7 +81,7 @@ public class TestDataSourceXAConnectionF } try { return method.invoke(ds, args); - } catch (InvocationTargetException e) { + } catch (final InvocationTargetException e) { throw e.getTargetException(); } } @@ -97,8 +97,8 @@ public class TestDataSourceXAConnectionF @Test public void testPhysicalClose() throws Exception { bmds.setMaxIdle(1); - Connection conn1 = bmds.getConnection(); - Connection conn2 = bmds.getConnection(); + final Connection conn1 = bmds.getConnection(); + final Connection conn2 = bmds.getConnection(); closeCounter.set(0); conn1.close(); assertEquals(0, closeCounter.get()); // stays idle in the pool Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java Mon Feb 8 21:56:48 2016 @@ -64,16 +64,16 @@ public class TestManagedConnection { transactionManager = new TransactionManagerImpl(); // create a driver connection factory - Properties properties = new Properties(); + final Properties properties = new Properties(); properties.setProperty("user", "username"); properties.setProperty("password", "password"); - ConnectionFactory connectionFactory = new DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver", properties); + final ConnectionFactory connectionFactory = new DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver", properties); // wrap it with a LocalXAConnectionFactory - XAConnectionFactory xaConnectionFactory = new UncooperativeLocalXAConnectionFactory(transactionManager, connectionFactory); + final XAConnectionFactory xaConnectionFactory = new UncooperativeLocalXAConnectionFactory(transactionManager, connectionFactory); // create the pool object factory - PoolableConnectionFactory factory = new PoolableConnectionFactory(xaConnectionFactory, null); + final PoolableConnectionFactory factory = new PoolableConnectionFactory(xaConnectionFactory, null); factory.setValidationQuery("SELECT DUMMY FROM DUAL"); factory.setDefaultReadOnly(Boolean.TRUE); factory.setDefaultAutoCommit(Boolean.TRUE); @@ -107,9 +107,9 @@ public class TestManagedConnection { transactionManager.begin(); try { - DelegatingConnection<?> connectionA = (DelegatingConnection<?>) getConnection(); + final DelegatingConnection<?> connectionA = (DelegatingConnection<?>) getConnection(); connectionA.close(); - } catch (SQLException e) { + } catch (final SQLException e) { // expected } transactionManager.commit(); @@ -127,10 +127,10 @@ public class TestManagedConnection { try { // inject our own TransactionRegistry which returns Uncooperative Transactions which always fail to enlist a XAResource - Field field = LocalXAConnectionFactory.class.getDeclaredField("transactionRegistry"); + final Field field = LocalXAConnectionFactory.class.getDeclaredField("transactionRegistry"); field.setAccessible(true); field.set(this, new UncooperativeTransactionRegistry(transactionManager)); - } catch (Exception e) { + } catch (final Exception e) { e.printStackTrace(); } } @@ -148,7 +148,7 @@ public class TestManagedConnection { throws SQLException { try { return new TransactionContext(this, new UncooperativeTransaction(transactionManager.getTransaction())); - } catch (SystemException e) { + } catch (final SystemException e) { return null; } } Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java Mon Feb 8 21:56:48 2016 @@ -66,16 +66,16 @@ public class TestManagedDataSource exten transactionManager = new TransactionManagerImpl(); // create a driver connection factory - Properties properties = new Properties(); + final Properties properties = new Properties(); properties.setProperty("user", "username"); properties.setProperty("password", "password"); - ConnectionFactory connectionFactory = new DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver", properties); + final ConnectionFactory connectionFactory = new DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver", properties); // wrap it with a LocalXAConnectionFactory - XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(transactionManager, connectionFactory); + final XAConnectionFactory xaConnectionFactory = new LocalXAConnectionFactory(transactionManager, connectionFactory); // create the pool object factory - PoolableConnectionFactory factory = + final PoolableConnectionFactory factory = new PoolableConnectionFactory(xaConnectionFactory, null); factory.setValidationQuery("SELECT DUMMY FROM DUAL"); factory.setDefaultReadOnly(Boolean.TRUE); @@ -124,8 +124,8 @@ public class TestManagedDataSource exten */ @Test public void testSharedConnection() throws Exception { - DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); - DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection(); + final DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); + final DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection(); assertFalse(connectionA.equals(connectionB)); assertFalse(connectionB.equals(connectionA)); @@ -139,7 +139,7 @@ public class TestManagedDataSource exten @Test public void testConnectionReturnOnCommit() throws Exception { transactionManager.begin(); - DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); + final DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); connectionA.close(); transactionManager.commit(); assertEquals(1, pool.getBorrowedCount()); @@ -150,7 +150,7 @@ public class TestManagedDataSource exten @Test public void testManagedConnectionEqualsSameDelegateNoUnderlyingAccess() throws Exception { // Get a maximal set of connections from the pool - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; for (int i = 0; i < c.length; i++) { c[i] = newConnection(); } @@ -161,12 +161,12 @@ public class TestManagedDataSource exten ds.setAccessToUnderlyingConnectionAllowed(false); // Grab a new connection - should get c[0]'s closed connection // so should be delegate-equivalent - Connection con = newConnection(); + final Connection con = newConnection(); Assert.assertNotEquals(c[0], con); Assert.assertEquals( ((DelegatingConnection<?>) c[0]).getInnermostDelegateInternal(), ((DelegatingConnection<?>) con).getInnermostDelegateInternal()); - for (Connection element : c) { + for (final Connection element : c) { element.close(); } ds.setAccessToUnderlyingConnectionAllowed(true); @@ -175,7 +175,7 @@ public class TestManagedDataSource exten @Test public void testManagedConnectionEqualsSameDelegate() throws Exception { // Get a maximal set of connections from the pool - Connection[] c = new Connection[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; for (int i = 0; i < c.length; i++) { c[i] = newConnection(); } @@ -184,12 +184,12 @@ public class TestManagedDataSource exten // Grab a new connection - should get c[0]'s closed connection // so should be delegate-equivalent - Connection con = newConnection(); + final Connection con = newConnection(); Assert.assertNotEquals(c[0], con); Assert.assertEquals( ((DelegatingConnection<?>) c[0]).getInnermostDelegateInternal(), ((DelegatingConnection<?>) con).getInnermostDelegateInternal()); - for (Connection element : c) { + for (final Connection element : c) { element.close(); } } @@ -199,8 +199,8 @@ public class TestManagedDataSource exten */ @Test public void testManagedConnectionEqualsReflexive() throws Exception { - Connection con = ds.getConnection(); - Connection con2 = con; + final Connection con = ds.getConnection(); + final Connection con2 = con; assertTrue(con2.equals(con)); assertTrue(con.equals(con2)); con.close(); @@ -208,8 +208,8 @@ public class TestManagedDataSource exten @Test public void testManagedConnectionEqualsFail() throws Exception { - Connection con1 = ds.getConnection(); - Connection con2 = ds.getConnection(); + final Connection con1 = ds.getConnection(); + final Connection con2 = ds.getConnection(); assertFalse(con1.equals(con2)); con1.close(); con2.close(); @@ -217,16 +217,16 @@ public class TestManagedDataSource exten @Test public void testManagedConnectionEqualsNull() throws Exception { - Connection con1 = ds.getConnection(); - Connection con2 = null; + final Connection con1 = ds.getConnection(); + final Connection con2 = null; assertFalse(con1.equals(con2)); con1.close(); } @Test public void testManagedConnectionEqualsType() throws Exception { - Connection con1 = ds.getConnection(); - Integer con2 = Integer.valueOf(0); + final Connection con1 = ds.getConnection(); + final Integer con2 = Integer.valueOf(0); assertFalse(con1.equals(con2)); con1.close(); } @@ -234,10 +234,10 @@ public class TestManagedDataSource exten @Test public void testManagedConnectionEqualInnermost() throws Exception { ds.setAccessToUnderlyingConnectionAllowed(true); - DelegatingConnection<?> con = (DelegatingConnection<?>) ds.getConnection(); - Connection inner = con.getInnermostDelegate(); + final DelegatingConnection<?> con = (DelegatingConnection<?>) ds.getConnection(); + final Connection inner = con.getInnermostDelegate(); ds.setAccessToUnderlyingConnectionAllowed(false); - DelegatingConnection<Connection> con2 = new DelegatingConnection<>(inner); + final DelegatingConnection<Connection> con2 = new DelegatingConnection<>(inner); assertFalse(con2.equals(con)); assertTrue(con.innermostDelegateEquals(con2.getInnermostDelegate())); assertTrue(con2.innermostDelegateEquals(inner)); Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java Mon Feb 8 21:56:48 2016 @@ -82,7 +82,7 @@ public class TestManagedDataSourceInTx e @Override @Test public void testConnectionsAreDistinct() throws Exception { - Connection[] conn = new Connection[getMaxTotal()]; + final Connection[] conn = new Connection[getMaxTotal()]; for(int i=0;i<conn.length;i++) { conn[i] = newConnection(); for(int j=0;j<i;j++) { @@ -96,7 +96,7 @@ public class TestManagedDataSourceInTx e ((DelegatingConnection<?>) conn[i]).getInnermostDelegateInternal()); } } - for (Connection element : conn) { + for (final Connection element : conn) { element.close(); } } @@ -104,9 +104,9 @@ public class TestManagedDataSourceInTx e @Override @Test public void testHashCode() throws Exception { - Connection conn1 = newConnection(); + final Connection conn1 = newConnection(); assertNotNull(conn1); - Connection conn2 = newConnection(); + final Connection conn2 = newConnection(); assertNotNull(conn2); // shared connections should not have the same hashcode @@ -116,8 +116,8 @@ public class TestManagedDataSourceInTx e @Override @Test public void testMaxTotal() throws Exception { - Transaction[] transactions = new Transaction[getMaxTotal()]; - Connection[] c = new Connection[getMaxTotal()]; + final Transaction[] transactions = new Transaction[getMaxTotal()]; + final Connection[] c = new Connection[getMaxTotal()]; for (int i = 0; i < c.length; i++) { // create a new connection in the current transaction c[i] = newConnection(); @@ -132,7 +132,7 @@ public class TestManagedDataSourceInTx e try { newConnection(); fail("Allowed to open more than DefaultMaxTotal connections."); - } catch (java.sql.SQLException e) { + } catch (final java.sql.SQLException e) { // should only be able to open 10 connections, so this test should // throw an exception } finally { @@ -153,11 +153,11 @@ public class TestManagedDataSourceInTx e assertNotNull(connection); // generate SQLWarning on connection - CallableStatement statement = connection.prepareCall("warning"); + final CallableStatement statement = connection.prepareCall("warning"); assertNotNull(connection.getWarnings()); // create a new shared connection - Connection sharedConnection = newConnection(); + final Connection sharedConnection = newConnection(); // shared connection should see warning assertNotNull(sharedConnection.getWarnings()); @@ -178,8 +178,8 @@ public class TestManagedDataSourceInTx e @Override @Test public void testSharedConnection() throws Exception { - DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); - DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection(); + final DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); + final DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection(); assertFalse(connectionA.equals(connectionB)); assertFalse(connectionB.equals(connectionA)); @@ -192,8 +192,8 @@ public class TestManagedDataSourceInTx e @Test public void testSharedTransactionConversion() throws Exception { - DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); - DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection(); + final DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); + final DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection(); // in a transaction the inner connections should be equal assertFalse(connectionA.equals(connectionB)); @@ -231,8 +231,8 @@ public class TestManagedDataSourceInTx e @Test public void testCloseInTransaction() throws Exception { - DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); - DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection(); + final DelegatingConnection<?> connectionA = (DelegatingConnection<?>) newConnection(); + final DelegatingConnection<?> connectionB = (DelegatingConnection<?>) newConnection(); assertFalse(connectionA.equals(connectionB)); assertFalse(connectionB.equals(connectionA)); @@ -242,7 +242,7 @@ public class TestManagedDataSourceInTx e connectionA.close(); connectionB.close(); - Connection connection = newConnection(); + final Connection connection = newConnection(); assertFalse("Connection should be open", connection.isClosed()); @@ -254,7 +254,7 @@ public class TestManagedDataSourceInTx e @Override @Test public void testAutoCommitBehavior() throws Exception { - Connection connection = newConnection(); + final Connection connection = newConnection(); // auto commit should be off assertFalse("Auto-commit should be disabled", connection.getAutoCommit()); @@ -263,7 +263,7 @@ public class TestManagedDataSourceInTx e try { connection.setAutoCommit(true); fail("setAutoCommit method should be disabled while enlisted in a transaction"); - } catch (SQLException e) { + } catch (final SQLException e) { // expected } @@ -276,7 +276,7 @@ public class TestManagedDataSourceInTx e @Test public void testCommit() throws Exception { - Connection connection = newConnection(); + final Connection connection = newConnection(); // connection should be open assertFalse("Connection should be open", connection.isClosed()); @@ -285,7 +285,7 @@ public class TestManagedDataSourceInTx e try { connection.commit(); fail("commit method should be disabled while enlisted in a transaction"); - } catch (SQLException e) { + } catch (final SQLException e) { // expected } @@ -298,7 +298,7 @@ public class TestManagedDataSourceInTx e @Test public void testReadOnly() throws Exception { - Connection connection = newConnection(); + final Connection connection = newConnection(); // NOTE: This test class uses connections that are read-only by default @@ -309,7 +309,7 @@ public class TestManagedDataSourceInTx e try { connection.setReadOnly(true); fail("setReadOnly method should be disabled while enlisted in a transaction"); - } catch (SQLException e) { + } catch (final SQLException e) { // expected } @@ -320,7 +320,7 @@ public class TestManagedDataSourceInTx e try { connection.setReadOnly(false); fail("setReadOnly method should be disabled while enlisted in a transaction"); - } catch (SQLException e) { + } catch (final SQLException e) { // expected } @@ -340,24 +340,24 @@ public class TestManagedDataSourceInTx e assertSame("statement.getConnection() should return the exact same connection instance that was used to create the statement", conn, statement.getConnection()); - ResultSet resultSet = statement.getResultSet(); + final ResultSet resultSet = statement.getResultSet(); assertFalse(isClosed(resultSet)); assertSame("resultSet.getStatement() should return the exact same statement instance that was used to create the result set", statement, resultSet.getStatement()); - ResultSet executeResultSet = statement.executeQuery("select * from dual"); + final ResultSet executeResultSet = statement.executeQuery("select * from dual"); assertFalse(isClosed(executeResultSet)); assertSame("resultSet.getStatement() should return the exact same statement instance that was used to create the result set", statement, executeResultSet.getStatement()); - ResultSet keysResultSet = statement.getGeneratedKeys(); + final ResultSet keysResultSet = statement.getGeneratedKeys(); assertFalse(isClosed(keysResultSet)); assertSame("resultSet.getStatement() should return the exact same statement instance that was used to create the result set", statement, keysResultSet.getStatement()); ResultSet preparedResultSet = null; if (statement instanceof PreparedStatement) { - PreparedStatement preparedStatement = (PreparedStatement) statement; + final PreparedStatement preparedStatement = (PreparedStatement) statement; preparedResultSet = preparedStatement.executeQuery(); assertFalse(isClosed(preparedResultSet)); assertSame("resultSet.getStatement() should return the exact same statement instance that was used to create the result set", Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TesterBasicXAConnection.java URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TesterBasicXAConnection.java?rev=1729274&r1=1729273&r2=1729274&view=diff ============================================================================== --- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TesterBasicXAConnection.java (original) +++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/managed/TesterBasicXAConnection.java Mon Feb 8 21:56:48 2016 @@ -62,7 +62,7 @@ public class TesterBasicXAConnection imp @Override public Connection getConnection() throws SQLException { if (conn == null) { - SQLException e = new SQLException("XAConnection closed"); + final SQLException e = new SQLException("XAConnection closed"); notifyConnectionErrorOccurred(e); throw e; } @@ -72,12 +72,12 @@ public class TesterBasicXAConnection imp closeHandle(); conn.clearWarnings(); } - } catch (SQLException e) { + } catch (final SQLException e) { notifyConnectionErrorOccurred(e); throw e; } handle = new ConnectionHandle(conn, this); - Connection proxy = (Connection) Proxy.newProxyInstance( + final Connection proxy = (Connection) Proxy.newProxyInstance( getClass().getClassLoader(), new Class[] { Connection.class }, handle); return proxy; @@ -88,7 +88,7 @@ public class TesterBasicXAConnection imp if (!conn.getAutoCommit()) { try { conn.rollback(); - } catch (SQLException e) { + } catch (final SQLException e) { e.printStackTrace(); } } @@ -138,19 +138,19 @@ public class TesterBasicXAConnection imp } protected void notifyConnectionClosed() { - ConnectionEvent event = new ConnectionEvent(this); - List<ConnectionEventListener> copy = new ArrayList<>( + final ConnectionEvent event = new ConnectionEvent(this); + final List<ConnectionEventListener> copy = new ArrayList<>( listeners); - for (ConnectionEventListener listener : copy) { + for (final ConnectionEventListener listener : copy) { listener.connectionClosed(event); } } protected void notifyConnectionErrorOccurred(SQLException e) { - ConnectionEvent event = new ConnectionEvent(this, e); - List<ConnectionEventListener> copy = new ArrayList<>( + final ConnectionEvent event = new ConnectionEvent(this, e); + final List<ConnectionEventListener> copy = new ArrayList<>( listeners); - for (ConnectionEventListener listener : copy) { + for (final ConnectionEventListener listener : copy) { listener.connectionErrorOccurred(event); } } @@ -173,7 +173,7 @@ public class TesterBasicXAConnection imp @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - String methodName = method.getName(); + final String methodName = method.getName(); if (methodName.equals("hashCode")) { return Integer.valueOf(System.identityHashCode(proxy)); } @@ -191,8 +191,8 @@ public class TesterBasicXAConnection imp } try { return method.invoke(conn, args); - } catch (InvocationTargetException e) { - Throwable te = e.getTargetException(); + } catch (final InvocationTargetException e) { + final Throwable te = e.getTargetException(); if (te instanceof SQLException) { xaconn.notifyConnectionErrorOccurred((SQLException) te); }