You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2017/10/27 20:29:53 UTC
commons-dbcp git commit: Use final.
Repository: commons-dbcp
Updated Branches:
refs/heads/master a9ab11f61 -> 845c820c0
Use final.
Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/845c820c
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/845c820c
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/845c820c
Branch: refs/heads/master
Commit: 845c820c03b613236e603a86d2ca91836abdc30a
Parents: a9ab11f
Author: Gary Gregory <gg...@apache.org>
Authored: Fri Oct 27 14:29:50 2017 -0600
Committer: Gary Gregory <gg...@apache.org>
Committed: Fri Oct 27 14:29:50 2017 -0600
----------------------------------------------------------------------
.../apache/commons/dbcp2/BasicDataSource.java | 14 ++--
.../java/org/apache/commons/dbcp2/PStmtKey.java | 38 +++++-----
.../commons/dbcp2/PoolableConnection.java | 2 +-
.../apache/commons/dbcp2/PoolingConnection.java | 7 +-
.../commons/dbcp2/TestBasicDataSource.java | 2 +-
.../commons/dbcp2/TestPoolingConnection.java | 80 ++++++++++----------
6 files changed, 72 insertions(+), 71 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/845c820c/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
index 11b16cc..30dd42e 100644
--- a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
@@ -1667,7 +1667,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
}
abandonedConfig.setRemoveAbandonedOnMaintenance(
removeAbandonedOnMaintenance);
- GenericObjectPool<?> gop = this.connectionPool;
+ final GenericObjectPool<?> gop = this.connectionPool;
if (gop != null) {
gop.setAbandonedConfig(abandonedConfig);
}
@@ -1703,7 +1703,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
abandonedConfig = new AbandonedConfig();
}
abandonedConfig.setRemoveAbandonedOnBorrow(removeAbandonedOnBorrow);
- GenericObjectPool<?> gop = this.connectionPool;
+ final GenericObjectPool<?> gop = this.connectionPool;
if (gop != null) {
gop.setAbandonedConfig(abandonedConfig);
}
@@ -1752,7 +1752,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
abandonedConfig = new AbandonedConfig();
}
abandonedConfig.setRemoveAbandonedTimeout(removeAbandonedTimeout);
- GenericObjectPool<?> gop = this.connectionPool;
+ final GenericObjectPool<?> gop = this.connectionPool;
if (gop != null) {
gop.setAbandonedConfig(abandonedConfig);
}
@@ -1784,7 +1784,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
abandonedConfig = new AbandonedConfig();
}
abandonedConfig.setLogAbandoned(logAbandoned);
- GenericObjectPool<?> gop = this.connectionPool;
+ final GenericObjectPool<?> gop = this.connectionPool;
if (gop != null) {
gop.setAbandonedConfig(abandonedConfig);
}
@@ -1812,7 +1812,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
abandonedConfig = new AbandonedConfig();
}
abandonedConfig.setLogWriter(logWriter);
- GenericObjectPool<?> gop = this.connectionPool;
+ final GenericObjectPool<?> gop = this.connectionPool;
if (gop != null) {
gop.setAbandonedConfig(abandonedConfig);
}
@@ -1849,7 +1849,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
abandonedConfig = new AbandonedConfig();
}
abandonedConfig.setUseUsageTracking(usageTracking);
- GenericObjectPool<?> gop = this.connectionPool;
+ final GenericObjectPool<?> gop = this.connectionPool;
if (gop != null) {
gop.setAbandonedConfig(abandonedConfig);
}
@@ -2214,7 +2214,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
final GenericObjectPoolConfig config = new GenericObjectPoolConfig();
updateJmxName(config);
config.setJmxEnabled(registeredJmxName != null); // Disable JMX on the underlying pool if the DS is not registered.
- GenericObjectPool<PoolableConnection> gop = createObjectPool(factory, config, abandonedConfig);
+ final GenericObjectPool<PoolableConnection> gop = createObjectPool(factory, config, abandonedConfig);
gop.setMaxTotal(maxTotal);
gop.setMaxIdle(maxIdle);
gop.setMinIdle(minIdle);
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/845c820c/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
index f1131f3..de6d95b 100644
--- a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
+++ b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
@@ -329,7 +329,7 @@ public class PStmtKey {
return buf.toString();
}
- public Statement createStatement(Connection connection) throws SQLException {
+ public Statement createStatement(final Connection connection) throws SQLException {
if (builder == null) throw new IllegalStateException("Prepared statement key is invalid.");
return builder.createStatement(connection);
}
@@ -346,8 +346,8 @@ public class PStmtKey {
*/
private class PreparedStatementSQL implements StatementBuilder {
@Override
- public Statement createStatement(Connection connection) throws SQLException {
- PreparedStatement statement = connection.prepareStatement(_sql);
+ public Statement createStatement(final Connection connection) throws SQLException {
+ final PreparedStatement statement = connection.prepareStatement(_sql);
return statement;
}
}
@@ -357,8 +357,8 @@ public class PStmtKey {
*/
private class PreparedStatementWithAutoGeneratedKeys implements StatementBuilder {
@Override
- public Statement createStatement(Connection connection) throws SQLException {
- PreparedStatement statement = connection.prepareStatement(
+ public Statement createStatement(final Connection connection) throws SQLException {
+ final PreparedStatement statement = connection.prepareStatement(
_sql, _autoGeneratedKeys.intValue());
return statement;
}
@@ -369,8 +369,8 @@ public class PStmtKey {
*/
private class PreparedStatementWithColumnIndexes implements StatementBuilder {
@Override
- public Statement createStatement(Connection connection) throws SQLException {
- PreparedStatement statement = connection.prepareStatement(
+ public Statement createStatement(final Connection connection) throws SQLException {
+ final PreparedStatement statement = connection.prepareStatement(
_sql, _columnIndexes);
return statement;
}
@@ -381,8 +381,8 @@ public class PStmtKey {
*/
private class PreparedStatementWithResultSetConcurrency implements StatementBuilder {
@Override
- public Statement createStatement(Connection connection) throws SQLException {
- PreparedStatement statement = connection.prepareStatement(
+ public Statement createStatement(final Connection connection) throws SQLException {
+ final PreparedStatement statement = connection.prepareStatement(
_sql, _resultSetType.intValue(), _resultSetConcurrency.intValue());
return statement;
}
@@ -393,8 +393,8 @@ public class PStmtKey {
*/
private class PreparedStatementWithResultSetHoldability implements StatementBuilder {
@Override
- public Statement createStatement(Connection connection) throws SQLException {
- PreparedStatement statement = connection.prepareStatement(
+ public Statement createStatement(final Connection connection) throws SQLException {
+ final PreparedStatement statement = connection.prepareStatement(
_sql, _resultSetType.intValue(), _resultSetConcurrency.intValue(),
_resultSetHoldability.intValue());
return statement;
@@ -406,8 +406,8 @@ public class PStmtKey {
*/
private class PreparedStatementWithColumnNames implements StatementBuilder {
@Override
- public Statement createStatement(Connection connection) throws SQLException {
- PreparedStatement statement = connection.prepareStatement(
+ public Statement createStatement(final Connection connection) throws SQLException {
+ final PreparedStatement statement = connection.prepareStatement(
_sql, _columnNames);
return statement;
}
@@ -418,8 +418,8 @@ public class PStmtKey {
*/
private class PreparedCallSQL implements StatementBuilder {
@Override
- public Statement createStatement(Connection connection) throws SQLException {
- PreparedStatement statement = connection.prepareCall(_sql);
+ public Statement createStatement(final Connection connection) throws SQLException {
+ final PreparedStatement statement = connection.prepareCall(_sql);
return statement;
}
}
@@ -429,8 +429,8 @@ public class PStmtKey {
*/
private class PreparedCallWithResultSetConcurrency implements StatementBuilder {
@Override
- public Statement createStatement(Connection connection) throws SQLException {
- PreparedStatement statement = connection.prepareCall(
+ public Statement createStatement(final Connection connection) throws SQLException {
+ final PreparedStatement statement = connection.prepareCall(
_sql, _resultSetType.intValue(), _resultSetConcurrency.intValue());
return statement;
}
@@ -441,8 +441,8 @@ public class PStmtKey {
*/
private class PreparedCallWithResultSetHoldability implements StatementBuilder {
@Override
- public Statement createStatement(Connection connection) throws SQLException {
- PreparedStatement statement = connection.prepareCall(
+ public Statement createStatement(final Connection connection) throws SQLException {
+ final PreparedStatement statement = connection.prepareCall(
_sql, _resultSetType.intValue(), _resultSetConcurrency.intValue(),
_resultSetHoldability.intValue());
return statement;
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/845c820c/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
index 72da67a..d4fd349 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
@@ -325,7 +325,7 @@ public class PoolableConnection extends DelegatingConnection<Connection>
fatalException = _disconnectionSqlCodes == null ? sqlState.startsWith(Utils.DISCONNECTION_SQL_CODE_PREFIX)
|| Utils.DISCONNECTION_SQL_CODES.contains(sqlState) : _disconnectionSqlCodes.contains(sqlState);
if (!fatalException) {
- SQLException nextException = e.getNextException();
+ final SQLException nextException = e.getNextException();
if (nextException != null && nextException != e) {
fatalException = isDisconnectionSqlException(e.getNextException());
}
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/845c820c/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java b/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
index aff6836..c000a65 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolingConnection.java
@@ -461,13 +461,14 @@ public class PoolingConnection extends DelegatingConnection<Connection>
throw new IllegalArgumentException("Prepared statement key is null or invalid.");
}
if (key.getStmtType() == StatementType.PREPARED_STATEMENT ) {
- PreparedStatement statement = (PreparedStatement) key.createStatement(getDelegate());
+ final PreparedStatement statement = (PreparedStatement) key.createStatement(getDelegate());
@SuppressWarnings({"rawtypes", "unchecked"}) // Unable to find way to avoid this
+ final
PoolablePreparedStatement pps = new PoolablePreparedStatement(statement, key, _pstmtPool, this);
return new DefaultPooledObject<DelegatingPreparedStatement>(pps);
}
- CallableStatement statement = (CallableStatement) key.createStatement(getDelegate());
- PoolableCallableStatement pcs = new PoolableCallableStatement(statement, key, _pstmtPool, this);
+ final CallableStatement statement = (CallableStatement) key.createStatement(getDelegate());
+ final PoolableCallableStatement pcs = new PoolableCallableStatement(statement, key, _pstmtPool, this);
return new DefaultPooledObject<DelegatingPreparedStatement>(pcs);
}
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/845c820c/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java b/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
index 58e576e..a6409cc 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
@@ -810,7 +810,7 @@ public class TestBasicDataSource extends TestConnectionPool {
properties.put("username", "foo");
properties.put("password", "bar");
final BasicDataSource ds = BasicDataSourceFactory.createDataSource(properties);
- boolean original = ds.getConnectionPool().getLogAbandoned();
+ final boolean original = ds.getConnectionPool().getLogAbandoned();
ds.setLogAbandoned(!original);
Assert.assertNotEquals(Boolean.valueOf(original),
Boolean.valueOf(ds.getConnectionPool().getLogAbandoned()));
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/845c820c/src/test/java/org/apache/commons/dbcp2/TestPoolingConnection.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/dbcp2/TestPoolingConnection.java b/src/test/java/org/apache/commons/dbcp2/TestPoolingConnection.java
index b9606cb..6a5d3ff 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestPoolingConnection.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestPoolingConnection.java
@@ -52,19 +52,19 @@ public class TestPoolingConnection {
@Test
public void testPrepareStatement() throws Exception {
- String sql = "select 'a' from dual";
- DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql);
- TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
+ final String sql = "select 'a' from dual";
+ final DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql);
+ final TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
// assert
assertEquals(sql, testStatement.getSql());
}
@Test
public void testPrepareStatementWithAutoGeneratedKeys() throws Exception {
- String sql = "select 'a' from dual";
- int autoGeneratedKeys = 0;
- DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, autoGeneratedKeys);
- TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
+ final String sql = "select 'a' from dual";
+ final int autoGeneratedKeys = 0;
+ final DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, autoGeneratedKeys);
+ final TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
// assert
assertEquals(sql, testStatement.getSql());
assertEquals(autoGeneratedKeys, testStatement.getAutoGeneratedKeys());
@@ -72,11 +72,11 @@ public class TestPoolingConnection {
@Test
public void testPrepareStatementWithResultSetConcurrency() throws Exception {
- String sql = "select 'a' from dual";
- int resultSetType = 0;
- int resultSetConcurrency = 0;
- DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, resultSetType, resultSetConcurrency);
- TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
+ final String sql = "select 'a' from dual";
+ final int resultSetType = 0;
+ final int resultSetConcurrency = 0;
+ final DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, resultSetType, resultSetConcurrency);
+ final TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
// assert
assertEquals(sql, testStatement.getSql());
assertEquals(resultSetType, testStatement.getResultSetType());
@@ -85,12 +85,12 @@ public class TestPoolingConnection {
@Test
public void testPrepareStatementWithResultSetHoldability() throws Exception {
- String sql = "select 'a' from dual";
- int resultSetType = 0;
- int resultSetConcurrency = 0;
- int resultSetHoldability = 0;
- DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
+ final String sql = "select 'a' from dual";
+ final int resultSetType = 0;
+ final int resultSetConcurrency = 0;
+ final int resultSetHoldability = 0;
+ final DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+ final TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
// assert
assertEquals(sql, testStatement.getSql());
assertEquals(resultSetType, testStatement.getResultSetType());
@@ -100,10 +100,10 @@ public class TestPoolingConnection {
@Test
public void testPrepareStatementWithColumnIndexes() throws Exception {
- String sql = "select 'a' from dual";
- int[] columnIndexes = new int[]{1};
- DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, columnIndexes);
- TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
+ final String sql = "select 'a' from dual";
+ final int[] columnIndexes = new int[]{1};
+ final DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, columnIndexes);
+ final TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
// assert
assertEquals(sql, testStatement.getSql());
assertArrayEquals(columnIndexes, testStatement.getColumnIndexes());
@@ -111,10 +111,10 @@ public class TestPoolingConnection {
@Test
public void testPrepareStatementWithColumnNames() throws Exception {
- String sql = "select 'a' from dual";
- String columnNames[] = new String[]{"columnName1"};
- DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, columnNames);
- TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
+ final String sql = "select 'a' from dual";
+ final String columnNames[] = new String[]{"columnName1"};
+ final DelegatingPreparedStatement statement = (DelegatingPreparedStatement)con.prepareStatement(sql, columnNames);
+ final TesterPreparedStatement testStatement = (TesterPreparedStatement) statement.getInnermostDelegate();
// assert
assertEquals(sql, testStatement.getSql());
assertArrayEquals(columnNames, testStatement.getColumnNames());
@@ -122,20 +122,20 @@ public class TestPoolingConnection {
@Test
public void testPrepareCall() throws Exception {
- String sql = "select 'a' from dual";
- DelegatingCallableStatement statement = (DelegatingCallableStatement)con.prepareCall(sql);
- TesterCallableStatement testStatement = (TesterCallableStatement) statement.getInnermostDelegate();
+ final String sql = "select 'a' from dual";
+ final DelegatingCallableStatement statement = (DelegatingCallableStatement)con.prepareCall(sql);
+ final TesterCallableStatement testStatement = (TesterCallableStatement) statement.getInnermostDelegate();
// assert
assertEquals(sql, testStatement.getSql());
}
@Test
public void testPrepareCallWithResultSetConcurrency() throws Exception {
- String sql = "select 'a' from dual";
- int resultSetType = 0;
- int resultSetConcurrency = 0;
- DelegatingCallableStatement statement = (DelegatingCallableStatement)con.prepareCall(sql, resultSetType, resultSetConcurrency);
- TesterCallableStatement testStatement = (TesterCallableStatement) statement.getInnermostDelegate();
+ final String sql = "select 'a' from dual";
+ final int resultSetType = 0;
+ final int resultSetConcurrency = 0;
+ final DelegatingCallableStatement statement = (DelegatingCallableStatement)con.prepareCall(sql, resultSetType, resultSetConcurrency);
+ final TesterCallableStatement testStatement = (TesterCallableStatement) statement.getInnermostDelegate();
// assert
assertEquals(sql, testStatement.getSql());
assertEquals(resultSetType, testStatement.getResultSetType());
@@ -144,12 +144,12 @@ public class TestPoolingConnection {
@Test
public void testPrepareCallWithResultSetHoldability() throws Exception {
- String sql = "select 'a' from dual";
- int resultSetType = 0;
- int resultSetConcurrency = 0;
- int resultSetHoldability = 0;
- DelegatingCallableStatement statement = (DelegatingCallableStatement)con.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
- TesterCallableStatement testStatement = (TesterCallableStatement) statement.getInnermostDelegate();
+ final String sql = "select 'a' from dual";
+ final int resultSetType = 0;
+ final int resultSetConcurrency = 0;
+ final int resultSetHoldability = 0;
+ final DelegatingCallableStatement statement = (DelegatingCallableStatement)con.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+ final TesterCallableStatement testStatement = (TesterCallableStatement) statement.getInnermostDelegate();
// assert
assertEquals(sql, testStatement.getSql());
assertEquals(resultSetType, testStatement.getResultSetType());