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 2021/01/13 19:36:16 UTC
[commons-dbcp] branch master updated: Minor Improvement: (#78)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
The following commit(s) were added to refs/heads/master by this push:
new e34be8b Minor Improvement: (#78)
e34be8b is described below
commit e34be8b2d501c1eb7f5961583c68552342edab1a
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Wed Jan 13 20:36:07 2021 +0100
Minor Improvement: (#78)
* Add final
* Unused import
* Unnecessary semicolon
* Use Standard Charset
* Simplify 'if' statement
* replace 'try finally' with 'try' with resources
* Replace javadoc with text plain
* Simplifiable conditional expression
---
.../org/apache/commons/dbcp2/BasicDataSource.java | 14 ++++----
.../apache/commons/dbcp2/DelegatingConnection.java | 2 +-
.../apache/commons/dbcp2/ObjectNameWrapper.java | 8 ++---
.../java/org/apache/commons/dbcp2/PStmtKey.java | 5 +--
.../apache/commons/dbcp2/PoolableConnection.java | 2 +-
.../commons/dbcp2/PoolableConnectionFactory.java | 2 +-
.../org/apache/commons/dbcp2/PoolingDriver.java | 4 +--
.../dbcp2/datasources/CPDSConnectionFactory.java | 8 ++---
.../datasources/InstanceKeyDataSourceFactory.java | 4 +--
.../datasources/KeyedCPDSConnectionFactory.java | 6 +---
.../apache/commons/dbcp2/datasources/PoolKey.java | 5 +--
.../commons/dbcp2/datasources/UserPassKey.java | 5 +--
.../dbcp2/managed/BasicManagedDataSource.java | 32 +++++++++---------
.../managed/DataSourceXAConnectionFactory.java | 34 +++++++++----------
.../dbcp2/managed/LocalXAConnectionFactory.java | 32 +++++++++---------
.../commons/dbcp2/managed/ManagedConnection.java | 32 +++++++++---------
.../commons/dbcp2/managed/ManagedDataSource.java | 32 +++++++++---------
.../commons/dbcp2/managed/TransactionContext.java | 34 +++++++++----------
.../dbcp2/managed/TransactionContextListener.java | 32 +++++++++---------
.../commons/dbcp2/managed/TransactionRegistry.java | 34 +++++++++----------
.../commons/dbcp2/managed/XAConnectionFactory.java | 32 +++++++++---------
.../org/apache/commons/dbcp2/StackMessageLog.java | 4 +--
.../apache/commons/dbcp2/TestBasicDataSource.java | 6 ++--
.../apache/commons/dbcp2/TestConnectionPool.java | 6 ++--
.../dbcp2/TestParallelCreationWithNoIdle.java | 4 +--
.../apache/commons/dbcp2/TestPoolingDriver.java | 3 +-
.../commons/dbcp2/TesterCallableStatement.java | 32 +++++++++---------
.../org/apache/commons/dbcp2/TesterConnection.java | 4 +--
.../commons/dbcp2/TesterDatabaseMetaData.java | 32 +++++++++---------
.../org/apache/commons/dbcp2/TesterResultSet.java | 14 ++------
.../org/apache/commons/dbcp2/TesterStatement.java | 6 ++--
.../datasources/TestPerUserPoolDataSource.java | 2 +-
.../dbcp2/managed/TestBasicManagedDataSource.java | 32 +++++++++---------
.../dbcp2/managed/TestConnectionWithNarayana.java | 36 ++++++++++----------
.../managed/TestDataSourceXAConnectionFactory.java | 34 +++++++++----------
.../dbcp2/managed/TestManagedConnection.java | 32 +++++++++---------
.../dbcp2/managed/TestManagedDataSource.java | 32 +++++++++---------
.../dbcp2/managed/TestManagedDataSourceInTx.java | 32 +++++++++---------
.../dbcp2/managed/TestSynchronizationOrder.java | 32 +++++++++---------
.../dbcp2/managed/TestTransactionContext.java | 32 +++++++++---------
.../dbcp2/managed/TesterBasicXAConnection.java | 38 +++++++++++-----------
41 files changed, 374 insertions(+), 398 deletions(-)
diff --git a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
index 5fdbb2c..62ca365 100644
--- a/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java
@@ -529,7 +529,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
// Set up the poolable connection factory
boolean success = false;
- PoolableConnectionFactory poolableConnectionFactory;
+ final PoolableConnectionFactory poolableConnectionFactory;
try {
poolableConnectionFactory = createPoolableConnectionFactory(driverConnectionFactory);
poolableConnectionFactory.setPoolStatements(poolPreparedStatements);
@@ -606,7 +606,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
*/
protected GenericObjectPool<PoolableConnection> createObjectPool(final PoolableConnectionFactory factory,
final GenericObjectPoolConfig<PoolableConnection> poolConfig, final AbandonedConfig abandonedConfig) {
- GenericObjectPool<PoolableConnection> gop;
+ final GenericObjectPool<PoolableConnection> gop;
if (abandonedConfig != null && (abandonedConfig.getRemoveAbandonedOnBorrow()
|| abandonedConfig.getRemoveAbandonedOnMaintenance())) {
gop = new GenericObjectPool<>(factory, poolConfig, abandonedConfig);
@@ -687,7 +687,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
*/
@Override
public boolean getAbandonedUsageTracking() {
- return abandonedConfig == null ? false : abandonedConfig.getUseUsageTracking();
+ return abandonedConfig != null && abandonedConfig.getUseUsageTracking();
}
/**
@@ -997,7 +997,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
*/
@Override
public boolean getLogAbandoned() {
- return abandonedConfig == null ? false : abandonedConfig.getLogAbandoned();
+ return abandonedConfig != null && abandonedConfig.getLogAbandoned();
}
/**
@@ -1212,7 +1212,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
*/
@Override
public boolean getRemoveAbandonedOnBorrow() {
- return abandonedConfig == null ? false : abandonedConfig.getRemoveAbandonedOnBorrow();
+ return abandonedConfig != null && abandonedConfig.getRemoveAbandonedOnBorrow();
}
/**
@@ -1233,7 +1233,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
*/
@Override
public boolean getRemoveAbandonedOnMaintenance() {
- return abandonedConfig == null ? false : abandonedConfig.getRemoveAbandonedOnMaintenance();
+ return abandonedConfig != null && abandonedConfig.getRemoveAbandonedOnMaintenance();
}
/**
@@ -1463,7 +1463,7 @@ public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBean
* @return boolean false if value is null, otherwise {@link String#isEmpty()}.
*/
private boolean isEmpty(final String value) {
- return value == null ? true : value.trim().isEmpty();
+ return value == null || value.trim().isEmpty();
}
/**
diff --git a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
index 11438f3..547b1e2 100644
--- a/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java
@@ -619,7 +619,7 @@ public class DelegatingConnection<C extends Connection> extends AbandonedTrace i
final List<AbandonedTrace> traces = getTrace();
if (traces != null && !traces.isEmpty()) {
final List<Exception> thrownList = new ArrayList<>();
- for (Object trace : traces) {
+ for (final Object trace : traces) {
if (trace instanceof Statement) {
try {
((Statement) trace).close();
diff --git a/src/main/java/org/apache/commons/dbcp2/ObjectNameWrapper.java b/src/main/java/org/apache/commons/dbcp2/ObjectNameWrapper.java
index 1cecc98..62b09f2 100644
--- a/src/main/java/org/apache/commons/dbcp2/ObjectNameWrapper.java
+++ b/src/main/java/org/apache/commons/dbcp2/ObjectNameWrapper.java
@@ -36,12 +36,12 @@ class ObjectNameWrapper {
private static final Log log = LogFactory.getLog(ObjectNameWrapper.class);
- private static MBeanServer MBEAN_SERVER = getPlatformMBeanServer();
+ private static final MBeanServer MBEAN_SERVER = getPlatformMBeanServer();
private static MBeanServer getPlatformMBeanServer() {
try {
return ManagementFactory.getPlatformMBeanServer();
- } catch (LinkageError | Exception e) {
+ } catch (final LinkageError | Exception e) {
// ignore - JMX not available
log.debug("Failed to get platform MBeanServer", e);
return null;
@@ -72,7 +72,7 @@ class ObjectNameWrapper {
}
try {
MBEAN_SERVER.registerMBean(object, objectName);
- } catch (LinkageError | Exception e) {
+ } catch (final LinkageError | Exception e) {
log.warn("Failed to complete JMX registration for " + objectName, e);
}
}
@@ -92,7 +92,7 @@ class ObjectNameWrapper {
if (MBEAN_SERVER.isRegistered(objectName)) {
try {
MBEAN_SERVER.unregisterMBean(objectName);
- } catch (LinkageError | Exception e) {
+ } catch (final LinkageError | Exception e) {
log.warn("Failed to complete JMX unregistration for " + objectName, e);
}
}
diff --git a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
index 188476d..96c6195 100644
--- a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
+++ b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
@@ -824,10 +824,7 @@ public class PStmtKey {
if (!Objects.equals(sql, other.sql)) {
return false;
}
- if (statementType != other.statementType) {
- return false;
- }
- return true;
+ return statementType == other.statementType;
}
/**
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
index d075d99..db7afa5 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolableConnection.java
@@ -45,7 +45,7 @@ public class PoolableConnection extends DelegatingConnection<Connection> impleme
static {
try {
MBEAN_SERVER = ManagementFactory.getPlatformMBeanServer();
- } catch (NoClassDefFoundError | Exception ex) {
+ } catch (final NoClassDefFoundError | Exception ex) {
// ignore - JMX not available
}
}
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
index 8609807..5598f13 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolableConnectionFactory.java
@@ -412,7 +412,7 @@ public class PoolableConnectionFactory implements PooledObjectFactory<PoolableCo
}
// Register this connection with JMX
- ObjectName connJmxName;
+ final ObjectName connJmxName;
if (dataSourceJmxObjectName == null) {
connJmxName = null;
} else {
diff --git a/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java b/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java
index f531859..4794301 100644
--- a/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java
+++ b/src/main/java/org/apache/commons/dbcp2/PoolingDriver.java
@@ -37,7 +37,7 @@ import org.apache.commons.pool2.ObjectPool;
*/
public class PoolingDriver implements Driver {
- /** Register myself with the {@link DriverManager}. */
+ /* Register myself with the {@link DriverManager}. */
static {
try {
DriverManager.registerDriver(new PoolingDriver());
@@ -140,7 +140,7 @@ public class PoolingDriver implements Driver {
@Override
public boolean acceptsURL(final String url) throws SQLException {
- return url == null ? false : url.startsWith(URL_PREFIX);
+ return url != null && url.startsWith(URL_PREFIX);
}
@Override
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java
index f5d2442..49e22a7 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java
@@ -149,7 +149,7 @@ class CPDSConnectionFactory
@Override
public synchronized PooledObject<PooledConnectionAndInfo> makeObject() {
- PooledConnectionAndInfo pci;
+ final PooledConnectionAndInfo pci;
try {
PooledConnection pc = null;
if (userName == null) {
@@ -225,11 +225,7 @@ class CPDSConnectionFactory
conn = pconn.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery(validationQuery);
- if (rset.next()) {
- valid = true;
- } else {
- valid = false;
- }
+ valid = rset.next();
if (rollbackAfterValidation) {
conn.rollback();
}
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java b/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java
index 48ebf8a..211ef7d 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/InstanceKeyDataSourceFactory.java
@@ -46,7 +46,7 @@ abstract class InstanceKeyDataSourceFactory implements ObjectFactory {
static synchronized String registerNewInstance(final InstanceKeyDataSource ds) {
int max = 0;
- for (String s : instanceMap.keySet()) {
+ for (final String s : instanceMap.keySet()) {
if (s != null) {
try {
max = Math.max(max, Integer.parseInt(s));
@@ -81,7 +81,7 @@ abstract class InstanceKeyDataSourceFactory implements ObjectFactory {
public static void closeAll() throws Exception {
// Get iterator to loop over all instances of this data source.
final List<Throwable> exceptionList = new ArrayList<>(instanceMap.size());
- for (Entry<String, InstanceKeyDataSource> next : instanceMap.entrySet()) {
+ for (final Entry<String, InstanceKeyDataSource> next : instanceMap.entrySet()) {
// Bullet-proof to avoid anything else but problems from InstanceKeyDataSource#close().
if (next != null) {
@SuppressWarnings("resource") final InstanceKeyDataSource value = next.getValue();
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
index 2fa878c..4f3de4b 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/KeyedCPDSConnectionFactory.java
@@ -191,11 +191,7 @@ class KeyedCPDSConnectionFactory implements KeyedPooledObjectFactory<UserPassKey
conn = pconn.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery(validationQuery);
- if (rset.next()) {
- valid = true;
- } else {
- valid = false;
- }
+ valid = rset.next();
if (rollbackAfterValidation) {
conn.rollback();
}
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java b/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java
index 4f9bc4f..0dcaace 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java
@@ -49,10 +49,7 @@ class PoolKey implements Serializable {
if (!Objects.equals(dataSourceName, other.dataSourceName)) {
return false;
}
- if (!Objects.equals(userName, other.userName)) {
- return false;
- }
- return true;
+ return Objects.equals(userName, other.userName);
}
@Override
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java b/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java
index 3de79d9..4112961 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java
@@ -76,10 +76,7 @@ class UserPassKey implements Serializable {
return false;
}
final UserPassKey other = (UserPassKey) obj;
- if (!Objects.equals(userName, other.userName)) {
- return false;
- }
- return true;
+ return Objects.equals(userName, other.userName);
}
/**
diff --git a/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java b/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
index 0a3dae6..25c7619 100644
--- a/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/managed/BasicManagedDataSource.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/main/java/org/apache/commons/dbcp2/managed/DataSourceXAConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/managed/DataSourceXAConnectionFactory.java
index b89ca63..bce97a5 100644
--- a/src/main/java/org/apache/commons/dbcp2/managed/DataSourceXAConnectionFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/managed/DataSourceXAConnectionFactory.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
@@ -140,7 +140,7 @@ public class DataSourceXAConnectionFactory implements XAConnectionFactory {
@Override
public Connection createConnection() throws SQLException {
// create a new XAConnection
- XAConnection xaConnection;
+ final XAConnection xaConnection;
if (userName == null) {
xaConnection = xaDataSource.getXAConnection();
} else {
diff --git a/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java
index 5783083..996a4e7 100644
--- a/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/managed/LocalXAConnectionFactory.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java b/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
index f9f86c3..b1c2adf 100644
--- a/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
+++ b/src/main/java/org/apache/commons/dbcp2/managed/ManagedConnection.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/main/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java b/src/main/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java
index 280bdeb..bf25d59 100644
--- a/src/main/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/managed/ManagedDataSource.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/main/java/org/apache/commons/dbcp2/managed/TransactionContext.java b/src/main/java/org/apache/commons/dbcp2/managed/TransactionContext.java
index f291e1f..9e0f913 100644
--- a/src/main/java/org/apache/commons/dbcp2/managed/TransactionContext.java
+++ b/src/main/java/org/apache/commons/dbcp2/managed/TransactionContext.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
@@ -133,7 +133,7 @@ public class TransactionContext {
if (!isActive()) {
final Transaction transaction = this.transactionRef.get();
listener.afterCompletion(TransactionContext.this,
- transaction == null ? false : transaction.getStatus() == Status.STATUS_COMMITTED);
+ transaction != null && transaction.getStatus() == Status.STATUS_COMMITTED);
return;
}
final Synchronization s = new Synchronization() {
diff --git a/src/main/java/org/apache/commons/dbcp2/managed/TransactionContextListener.java b/src/main/java/org/apache/commons/dbcp2/managed/TransactionContextListener.java
index 332ead6..4d73855 100644
--- a/src/main/java/org/apache/commons/dbcp2/managed/TransactionContextListener.java
+++ b/src/main/java/org/apache/commons/dbcp2/managed/TransactionContextListener.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/main/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java b/src/main/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java
index 1a62e9d..f2b49f6 100644
--- a/src/main/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java
+++ b/src/main/java/org/apache/commons/dbcp2/managed/TransactionRegistry.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
@@ -148,7 +148,7 @@ public class TransactionRegistry {
}
private Connection getConnectionKey(final Connection connection) {
- Connection result;
+ final Connection result;
if (connection instanceof DelegatingConnection) {
result = ((DelegatingConnection<?>) connection).getInnermostDelegateInternal();
} else {
diff --git a/src/main/java/org/apache/commons/dbcp2/managed/XAConnectionFactory.java b/src/main/java/org/apache/commons/dbcp2/managed/XAConnectionFactory.java
index 60292ad..026cc62 100644
--- a/src/main/java/org/apache/commons/dbcp2/managed/XAConnectionFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/managed/XAConnectionFactory.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java b/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
index f2a3e67..fc62925 100644
--- a/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
+++ b/src/test/java/org/apache/commons/dbcp2/StackMessageLog.java
@@ -34,8 +34,8 @@ import org.apache.commons.logging.impl.SimpleLog;
public class StackMessageLog extends SimpleLog {
private static final long serialVersionUID = 1L;
- private static Stack<String> messageStack = new Stack<>();
- private static Lock lock = new ReentrantLock();
+ private static final Stack<String> messageStack = new Stack<>();
+ private static final Lock lock = new ReentrantLock();
public StackMessageLog(final String name) {
super(name);
diff --git a/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java b/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
index 5989ad9..dbcb794 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestBasicDataSource.java
@@ -889,7 +889,7 @@ public class TestBasicDataSource extends TestConnectionPool {
@Test
public void testCreateConnectionFactory() throws Exception {
- /** not set ConnectionFactoryClassName */
+ /* not set ConnectionFactoryClassName */
Properties properties = new Properties();
properties.put("initialSize", "1");
properties.put("driverClassName", "org.apache.commons.dbcp2.TesterDriver");
@@ -902,7 +902,7 @@ public class TestBasicDataSource extends TestConnectionPool {
conn.close();
ds.close();
- /** set ConnectionFactoryClassName */
+ /* set ConnectionFactoryClassName */
properties = new Properties();
properties.put("initialSize", "1");
properties.put("driverClassName", "org.apache.commons.dbcp2.TesterDriver");
@@ -1026,7 +1026,7 @@ public class TestBasicDataSource extends TestConnectionPool {
*/
class TesterConnRequestCountDriver extends TesterDriver {
private static final String CONNECT_STRING = "jdbc:apache:commons:testerConnRequestCountDriver";
- private static AtomicInteger connectionRequestCount = new AtomicInteger(0);
+ private static final AtomicInteger connectionRequestCount = new AtomicInteger(0);
public TesterConnRequestCountDriver() {
// DBCP expects an explicit no-arg constructor
diff --git a/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java b/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
index 6d9ddfb..2d80486 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestConnectionPool.java
@@ -75,7 +75,7 @@ public abstract class TestConnectionPool {
}
/** Connections opened during the course of a test */
- protected Stack<Connection> connections = new Stack<>();
+ protected final Stack<Connection> connections = new Stack<>();
/** Acquire a connection and push it onto the connections stack */
protected Connection newConnection() throws Exception {
@@ -578,7 +578,7 @@ public abstract class TestConnectionPool {
}
class TestThread implements Runnable {
- java.util.Random _random = new java.util.Random();
+ final java.util.Random _random = new java.util.Random();
boolean _complete = false;
boolean _failed = false;
int _iter = 100;
@@ -615,7 +615,7 @@ public abstract class TestConnectionPool {
try (Connection conn = newConnection();
PreparedStatement stmt = conn.prepareStatement(
"select 'literal', SYSDATE from dual");
- ResultSet rset = stmt.executeQuery();) {
+ ResultSet rset = stmt.executeQuery()) {
try {
Thread.sleep(_random.nextInt(_delay));
} catch(final Exception e) {
diff --git a/src/test/java/org/apache/commons/dbcp2/TestParallelCreationWithNoIdle.java b/src/test/java/org/apache/commons/dbcp2/TestParallelCreationWithNoIdle.java
index 1b2e4f9..3eb2f19 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestParallelCreationWithNoIdle.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestParallelCreationWithNoIdle.java
@@ -112,7 +112,7 @@ public class TestParallelCreationWithNoIdle {
class TestThread extends Thread {
- java.util.Random _random = new java.util.Random();
+ final java.util.Random _random = new java.util.Random();
final int iter;
final int delay;
final int delayAfter;
@@ -131,7 +131,7 @@ public class TestParallelCreationWithNoIdle {
for (int i = 0; i < iter; i++) {
sleepMax(delay);
try (Connection conn = ds.getConnection();
- PreparedStatement stmt = conn.prepareStatement("select 'literal', SYSDATE from dual");) {
+ PreparedStatement stmt = conn.prepareStatement("select 'literal', SYSDATE from dual")) {
// System.out.println("Got Connection " + Thread.currentThread().toString());
final ResultSet rset = stmt.executeQuery();
rset.next();
diff --git a/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java b/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
index d65b701..6782eed 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestPoolingDriver.java
@@ -27,6 +27,7 @@ import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
@@ -208,7 +209,7 @@ public class TestPoolingDriver extends TestConnectionPool {
@Test
public void testLogWriter() throws Exception {
final PrintStream ps = new PrintStream(new ByteArrayOutputStream(), false, "UTF-8");
- final PrintWriter pw = new PrintWriter(new OutputStreamWriter(new ByteArrayOutputStream(), "UTF-8"));
+ final PrintWriter pw = new PrintWriter(new OutputStreamWriter(new ByteArrayOutputStream(), StandardCharsets.UTF_8));
System.setErr(new PrintStream(new ByteArrayOutputStream(), false, "UTF-8"));
SQLException ex;
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java b/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java
index 36010ad..5230a03 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterCallableStatement.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2;
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterConnection.java b/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
index ed26695..1fe79af 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterConnection.java
@@ -44,13 +44,13 @@ public class TesterConnection extends AbandonedTrace implements Connection {
protected boolean _aborted = false;
protected boolean _autoCommit = true;
protected int _transactionIsolation = 1;
- protected DatabaseMetaData _metaData = new TesterDatabaseMetaData();
+ protected final DatabaseMetaData _metaData = new TesterDatabaseMetaData();
protected String _catalog;
protected String schema;
protected Map<String,Class<?>> _typeMap;
protected boolean _readOnly;
protected SQLWarning warnings;
- protected String userName;
+ protected final String userName;
protected Exception failure;
protected boolean sqlExceptionOnClose;
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterDatabaseMetaData.java b/src/test/java/org/apache/commons/dbcp2/TesterDatabaseMetaData.java
index 124829b..586f6fe 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterDatabaseMetaData.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterDatabaseMetaData.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2;
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java b/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
index 73b5545..7dcba8d 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterResultSet.java
@@ -18,6 +18,7 @@
package org.apache.commons.dbcp2;
import java.math.BigDecimal;
+import java.nio.charset.StandardCharsets;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
@@ -32,7 +33,6 @@ import java.util.Calendar;
import java.util.Map;
import java.io.InputStream;
import java.io.Reader;
-import java.io.UnsupportedEncodingException;
import java.sql.NClob;
import java.sql.RowId;
import java.sql.SQLXML;
@@ -241,12 +241,7 @@ public class TesterResultSet extends AbandonedTrace implements ResultSet {
@Override
public byte[] getBytes(final String columnName) throws SQLException {
checkOpen();
- try {
- return columnName.getBytes("UTF-8");
- } catch (final UnsupportedEncodingException e) {
- // Impossible. JVMs are required to support UTF-8
- return null;
- }
+ return columnName.getBytes(StandardCharsets.UTF_8);
}
@Override
@@ -675,10 +670,7 @@ public java.sql.Date getDate(final int columnIndex, final Calendar cal) throws S
_currentRow++;
return _currentRow < _data.length;
}
- if(--_rowsLeft > 0) {
- return true;
- }
- return false;
+ return --_rowsLeft > 0;
}
@Override
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterStatement.java b/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
index 42878a0..e9238af 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterStatement.java
@@ -28,10 +28,10 @@ import java.sql.Statement;
*/
public class TesterStatement extends AbandonedTrace implements Statement {
- protected Connection _connection;
+ protected final Connection _connection;
protected boolean _open = true;
- protected long _rowsUpdated = 1;
- protected boolean _executeResponse = true;
+ protected final long _rowsUpdated = 1;
+ protected final boolean _executeResponse = true;
protected int _maxFieldSize = 1024;
protected long _maxRows = 1024;
protected boolean _escapeProcessing;
diff --git a/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java b/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
index 036456c..368dd87 100644
--- a/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
+++ b/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
@@ -93,7 +93,7 @@ public class TestPerUserPoolDataSource extends TestConnectionPool {
@Test
public void testIncorrectPassword() throws Exception {
// Use bad password
- try (Connection c = ds.getConnection("u1", "zlsafjk");){
+ try (Connection c = ds.getConnection("u1", "zlsafjk")){
fail("Able to retrieve connection with incorrect password");
} catch (final SQLException e1) {
// should fail
diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java b/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
index f1c83d3..35e6277 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestBasicManagedDataSource.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TestConnectionWithNarayana.java b/src/test/java/org/apache/commons/dbcp2/managed/TestConnectionWithNarayana.java
index 5a01e62..3798511 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestConnectionWithNarayana.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestConnectionWithNarayana.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
@@ -43,7 +43,7 @@ public class TestConnectionWithNarayana {
private static final String CREATE_STMT = "CREATE TABLE TEST_DATA (KEY VARCHAR(100), ID BIGINT, VALUE DOUBLE PRECISION, INFO TEXT, TS TIMESTAMP)";
private static final String INSERT_STMT = "INSERT INTO TEST_DATA (KEY, ID, VALUE, INFO, TS) VALUES (?,?,?,?,?)";
private static final String SELECT_STMT = "SELECT KEY, ID, VALUE, INFO, TS FROM TEST_DATA LIMIT 1";
- private static String PAYLOAD;
+ private static final String PAYLOAD;
private static final String DROP_STMT = "DROP TABLE TEST_DATA";
static {
@@ -127,7 +127,7 @@ public class TestConnectionWithNarayana {
public void testConnectionCommitAfterTimeout() throws Exception {
mds.getTransactionManager().setTransactionTimeout(1);
mds.getTransactionManager().begin();
- try (Connection conn = mds.getConnection();) {
+ try (Connection conn = mds.getConnection()) {
do {
Thread.sleep(1000);
} while (mds.getTransactionManager().getTransaction().getStatus() != Status.STATUS_ROLLEDBACK);
diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java b/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
index 0119938..d6ac466 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestDataSourceXAConnectionFactory.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
@@ -43,7 +43,7 @@ public class TestDataSourceXAConnectionFactory extends TestBasicDataSource {
protected BasicManagedDataSource bmds;
- public AtomicInteger closeCounter = new AtomicInteger();
+ public final AtomicInteger closeCounter = new AtomicInteger();
@Override
@BeforeEach
diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java
index 84969f7..3080034 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
index ae12afc..85af515 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
index 0cdd7a0..5b0df1a 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSourceInTx.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TestSynchronizationOrder.java b/src/test/java/org/apache/commons/dbcp2/managed/TestSynchronizationOrder.java
index 8797b2b..234ebf9 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestSynchronizationOrder.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestSynchronizationOrder.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TestTransactionContext.java b/src/test/java/org/apache/commons/dbcp2/managed/TestTransactionContext.java
index 35a03cb..5ee0eba 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestTransactionContext.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestTransactionContext.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
diff --git a/src/test/java/org/apache/commons/dbcp2/managed/TesterBasicXAConnection.java b/src/test/java/org/apache/commons/dbcp2/managed/TesterBasicXAConnection.java
index e8183ad..d9b48a1 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TesterBasicXAConnection.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TesterBasicXAConnection.java
@@ -1,19 +1,19 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+/*
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
*/
package org.apache.commons.dbcp2.managed;
@@ -46,9 +46,9 @@ public class TesterBasicXAConnection implements XAConnection {
public ConnectionHandle handle;
- public List<ConnectionEventListener> listeners = new LinkedList<>();
+ public final List<ConnectionEventListener> listeners = new LinkedList<>();
- public AtomicInteger closeCounter;
+ public final AtomicInteger closeCounter;
public TesterBasicXAConnection(final Connection conn, final AtomicInteger closeCounter) {
this.conn = conn;
@@ -163,7 +163,7 @@ public class TesterBasicXAConnection implements XAConnection {
public Connection conn;
- public TesterBasicXAConnection xaconn;
+ public final TesterBasicXAConnection xaconn;
public ConnectionHandle(final Connection conn, final TesterBasicXAConnection xaconn) {
this.conn = conn;