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 0125593 Bump to next development version
0125593 is described below
commit 012559340277ee7bf4f74aaa0e1c75f46cdf6ece
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jun 2 09:31:13 2021 -0400
Bump to next development version
---
.../commons/dbcp2/ConnectionFactoryFactory.java | 2 +-
.../java/org/apache/commons/dbcp2/Constants.java | 16 +++++++++-
src/main/java/org/apache/commons/dbcp2/Utils.java | 4 +--
.../dbcp2/cpdsadapter/DriverAdapterCPDS.java | 37 ++++++++++------------
.../dbcp2/TestDriverManagerConnectionFactory.java | 4 +--
.../commons/dbcp2/TestPoolingDataSource.java | 24 +++++++-------
.../org/apache/commons/dbcp2/TesterDriver.java | 4 +--
.../dbcp2/cpdsadapter/TestDriverAdapterCPDS.java | 5 +--
.../dbcp2/managed/TestManagedConnection.java | 5 +--
.../managed/TestManagedConnectionCachedState.java | 5 +--
.../dbcp2/managed/TestManagedDataSource.java | 5 +--
.../managed/TestPoolableManagedConnection.java | 5 +--
12 files changed, 66 insertions(+), 50 deletions(-)
diff --git
a/src/main/java/org/apache/commons/dbcp2/ConnectionFactoryFactory.java
b/src/main/java/org/apache/commons/dbcp2/ConnectionFactoryFactory.java
index d50aa74..dcc8a34 100644
--- a/src/main/java/org/apache/commons/dbcp2/ConnectionFactoryFactory.java
+++ b/src/main/java/org/apache/commons/dbcp2/ConnectionFactoryFactory.java
@@ -45,7 +45,7 @@ class ConnectionFactoryFactory {
// Set up the driver connection factory we will use
final String user = basicDataSource.getUsername();
if (user != null) {
- connectionProperties.put("user", user);
+ connectionProperties.put(Constants.KEY_USER, user);
} else {
basicDataSource.log("DBCP DataSource configured without a
'username'");
}
diff --git a/src/main/java/org/apache/commons/dbcp2/Constants.java
b/src/main/java/org/apache/commons/dbcp2/Constants.java
index 4f09839..26bf3df 100644
--- a/src/main/java/org/apache/commons/dbcp2/Constants.java
+++ b/src/main/java/org/apache/commons/dbcp2/Constants.java
@@ -17,7 +17,7 @@
package org.apache.commons.dbcp2;
/**
- * Constants for use with JMX.
+ * Constants.
*
* @since 2.0
*/
@@ -31,4 +31,18 @@ public class Constants {
public static final String JMX_STATEMENT_POOL_BASE_EXT =
JMX_CONNECTION_BASE_EXT;
public static final String JMX_STATEMENT_POOL_PREFIX =
",statementpool=statements";
+
+ /**
+ * JDBC properties and URL key for passwords.
+ *
+ * @since 2.9.0
+ */
+ public static final String KEY_PASSWORD = "password";
+
+ /**
+ * JDBC properties and URL key for users.
+ *
+ * @since 2.9.0
+ */
+ public static final String KEY_USER = "user";
}
diff --git a/src/main/java/org/apache/commons/dbcp2/Utils.java
b/src/main/java/org/apache/commons/dbcp2/Utils.java
index 5a2f5af..9c0e0d9 100644
--- a/src/main/java/org/apache/commons/dbcp2/Utils.java
+++ b/src/main/java/org/apache/commons/dbcp2/Utils.java
@@ -91,8 +91,8 @@ public final class Utils {
public static Properties cloneWithoutCredentials(final Properties
properties) {
if (properties != null) {
final Properties temp = (Properties) properties.clone();
- temp.remove("user");
- temp.remove("password");
+ temp.remove(Constants.KEY_USER);
+ temp.remove(Constants.KEY_PASSWORD);
return temp;
}
return properties;
diff --git
a/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
b/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
index 1d67dcb..e0fe5a6 100644
--- a/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
+++ b/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
@@ -38,6 +38,7 @@ import javax.sql.ConnectionPoolDataSource;
import javax.sql.PooledConnection;
import org.apache.commons.dbcp2.BasicDataSource;
+import org.apache.commons.dbcp2.Constants;
import org.apache.commons.dbcp2.DelegatingPreparedStatement;
import org.apache.commons.dbcp2.PStmtKey;
import org.apache.commons.dbcp2.Utils;
@@ -78,10 +79,6 @@ import
org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
*/
public class DriverAdapterCPDS implements ConnectionPoolDataSource,
Referenceable, Serializable, ObjectFactory {
- private static final String KEY_USER = "user";
-
- private static final String KEY_PASSWORD = "password";
-
private static final long serialVersionUID = -4820523787212147844L;
private static final String GET_CONNECTION_CALLED = "A PooledConnection
was already requested from this source, "
@@ -268,11 +265,11 @@ public class DriverAdapterCPDS implements
ConnectionPoolDataSource, Referenceabl
if (isNotEmpty(ra)) {
setUrl(getStringContent(ra));
}
- ra = ref.get(KEY_USER);
+ ra = ref.get(Constants.KEY_USER);
if (isNotEmpty(ra)) {
setUser(getStringContent(ra));
}
- ra = ref.get(KEY_PASSWORD);
+ ra = ref.get(Constants.KEY_PASSWORD);
if (isNotEmpty(ra)) {
setPassword(getStringContent(ra));
}
@@ -359,11 +356,11 @@ public class DriverAdapterCPDS implements
ConnectionPoolDataSource, Referenceabl
throws SQLException {
getConnectionCalled = true;
PooledConnectionImpl pooledConnection = null;
- // Workaround for buggy WebLogic 5.1 classloader - ignore the
exception upon first invocation.
+ // Workaround for buggy WebLogic 5.1 class loader - ignore the
exception upon first invocation.
try {
if (connectionProperties != null) {
- update(connectionProperties, KEY_USER, pooledUserName);
- update(connectionProperties, KEY_PASSWORD, pooledUserPassword);
+ update(connectionProperties, Constants.KEY_USER,
pooledUserName);
+ update(connectionProperties, Constants.KEY_PASSWORD,
pooledUserPassword);
pooledConnection = new PooledConnectionImpl(
DriverManager.getConnection(getUrl(),
connectionProperties));
} else {
@@ -389,13 +386,13 @@ public class DriverAdapterCPDS implements
ConnectionPoolDataSource, Referenceabl
config.setMaxWaitMillis(0);
config.setMaxIdlePerKey(getMaxIdle());
if (getMaxPreparedStatements() <= 0) {
- // since there is no limit, create a prepared statement pool
with an eviction thread;
+ // Since there is no limit, create a prepared statement pool
with an eviction thread;
// evictor settings are the same as the connection pool
settings.
config.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
config.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun());
config.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
} else {
- // since there is a limit, create a prepared statement pool
without an eviction thread;
+ // Since there is a limit, create a prepared statement pool
without an eviction thread;
// pool has LRU functionality so when the limit is reached,
15% of the pool is cleared.
// see
org.apache.commons.pool2.impl.GenericKeyedObjectPool.clearOldest method
config.setMaxTotal(getMaxPreparedStatements());
@@ -422,8 +419,8 @@ public class DriverAdapterCPDS implements
ConnectionPoolDataSource, Referenceabl
ref.add(new StringRefAddr("description", getDescription()));
ref.add(new StringRefAddr("driver", getDriver()));
ref.add(new StringRefAddr("loginTimeout",
String.valueOf(getLoginTimeout())));
- ref.add(new StringRefAddr(KEY_PASSWORD, getPassword()));
- ref.add(new StringRefAddr(KEY_USER, getUser()));
+ ref.add(new StringRefAddr(Constants.KEY_PASSWORD, getPassword()));
+ ref.add(new StringRefAddr(Constants.KEY_USER, getUser()));
ref.add(new StringRefAddr("url", getUrl()));
ref.add(new StringRefAddr("poolPreparedStatements",
String.valueOf(isPoolPreparedStatements())));
@@ -519,11 +516,11 @@ public class DriverAdapterCPDS implements
ConnectionPoolDataSource, Referenceabl
assertInitializationAllowed();
connectionProperties = props;
if (connectionProperties != null) {
- if (connectionProperties.containsKey(KEY_USER)) {
- setUser(connectionProperties.getProperty(KEY_USER));
+ if (connectionProperties.containsKey(Constants.KEY_USER)) {
+ setUser(connectionProperties.getProperty(Constants.KEY_USER));
}
- if (connectionProperties.containsKey(KEY_PASSWORD)) {
- setPassword(connectionProperties.getProperty(KEY_PASSWORD));
+ if (connectionProperties.containsKey(Constants.KEY_PASSWORD)) {
+
setPassword(connectionProperties.getProperty(Constants.KEY_PASSWORD));
}
}
}
@@ -632,7 +629,7 @@ public class DriverAdapterCPDS implements
ConnectionPoolDataSource, Referenceabl
public void setPassword(final char[] userPassword) {
assertInitializationAllowed();
this.userPassword = Utils.clone(userPassword);
- update(connectionProperties, KEY_PASSWORD,
Utils.toString(this.userPassword));
+ update(connectionProperties, Constants.KEY_PASSWORD,
Utils.toString(this.userPassword));
}
/**
@@ -644,7 +641,7 @@ public class DriverAdapterCPDS implements
ConnectionPoolDataSource, Referenceabl
public void setPassword(final String userPassword) {
assertInitializationAllowed();
this.userPassword = Utils.toCharArray(userPassword);
- update(connectionProperties, KEY_PASSWORD, userPassword);
+ update(connectionProperties, Constants.KEY_PASSWORD, userPassword);
}
/**
@@ -692,7 +689,7 @@ public class DriverAdapterCPDS implements
ConnectionPoolDataSource, Referenceabl
public void setUser(final String v) {
assertInitializationAllowed();
this.userName = v;
- update(connectionProperties, KEY_USER, v);
+ update(connectionProperties, Constants.KEY_USER, v);
}
/**
diff --git
a/src/test/java/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
b/src/test/java/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
index c46ff5e..830280a 100644
---
a/src/test/java/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
+++
b/src/test/java/org/apache/commons/dbcp2/TestDriverManagerConnectionFactory.java
@@ -98,8 +98,8 @@ public class TestDriverManagerConnectionFactory {
config.setMaxIdle(0);
final Properties properties = new Properties();
// The names "user" and "password" are specified in
java.sql.DriverManager.getConnection(String, String, String)
- properties.put("user", "foo");
- properties.put("password", "bar");
+ properties.setProperty(Constants.KEY_USER, "foo");
+ properties.setProperty(Constants.KEY_PASSWORD, "bar");
final ConnectionFactory connectionFactory = withProperties ?
new
DriverManagerConnectionFactory("jdbc:apache:commons:testdriver", properties) :
new
DriverManagerConnectionFactory("jdbc:apache:commons:testdriver", "foo", "bar");
diff --git a/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
b/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
index 310fbb4..76d7730 100644
--- a/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
+++ b/src/test/java/org/apache/commons/dbcp2/TestPoolingDataSource.java
@@ -50,13 +50,13 @@ public class TestPoolingDataSource extends
TestConnectionPool {
@BeforeEach
public void setUp() throws Exception {
- final Properties props = new Properties();
- props.setProperty("user", "userName");
- props.setProperty("password", "password");
+ final Properties properties = new Properties();
+ properties.setProperty(Constants.KEY_USER, "userName");
+ properties.setProperty(Constants.KEY_PASSWORD, "password");
final PoolableConnectionFactory factory =
new PoolableConnectionFactory(
new DriverConnectionFactory(new TesterDriver(),
- "jdbc:apache:commons:testdriver", props),
+ "jdbc:apache:commons:testdriver", properties),
null);
factory.setValidationQuery("SELECT DUMMY FROM DUAL");
factory.setDefaultReadOnly(Boolean.TRUE);
@@ -156,13 +156,13 @@ public class TestPoolingDataSource extends
TestConnectionPool {
*/
@Test
public void testFixFactoryConfig() throws Exception {
- final Properties props = new Properties();
- props.setProperty("user", "userName");
- props.setProperty("password", "password");
+ final Properties properties = new Properties();
+ properties.setProperty(Constants.KEY_USER, "userName");
+ properties.setProperty(Constants.KEY_PASSWORD, "password");
final PoolableConnectionFactory f =
new PoolableConnectionFactory(
new DriverConnectionFactory(new TesterDriver(),
- "jdbc:apache:commons:testdriver", props),
+ "jdbc:apache:commons:testdriver", properties),
null);
f.setValidationQuery("SELECT DUMMY FROM DUAL");
f.setDefaultReadOnly(Boolean.TRUE);
@@ -178,13 +178,13 @@ public class TestPoolingDataSource extends
TestConnectionPool {
@Test
public void testClose() throws Exception {
- final Properties props = new Properties();
- props.setProperty("user", "userName");
- props.setProperty("password", "password");
+ final Properties properties = new Properties();
+ properties.setProperty(Constants.KEY_USER, "userName");
+ properties.setProperty(Constants.KEY_PASSWORD, "password");
final PoolableConnectionFactory f =
new PoolableConnectionFactory(
new DriverConnectionFactory(new TesterDriver(),
- "jdbc:apache:commons:testdriver", props),
+ "jdbc:apache:commons:testdriver", properties),
null);
f.setValidationQuery("SELECT DUMMY FROM DUAL");
f.setDefaultReadOnly(Boolean.TRUE);
diff --git a/src/test/java/org/apache/commons/dbcp2/TesterDriver.java
b/src/test/java/org/apache/commons/dbcp2/TesterDriver.java
index 618a1b6..6b59b09 100644
--- a/src/test/java/org/apache/commons/dbcp2/TesterDriver.java
+++ b/src/test/java/org/apache/commons/dbcp2/TesterDriver.java
@@ -94,8 +94,8 @@ public class TesterDriver implements Driver {
String password = "test";
if (info != null)
{
- userName = info.getProperty("user");
- password = info.getProperty("password");
+ userName = info.getProperty(Constants.KEY_USER);
+ password = info.getProperty(Constants.KEY_PASSWORD);
if (userName == null) {
final String[] parts = url.split(";");
userName = parts[1];
diff --git
a/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java
b/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java
index c1a29a5..865b038 100644
---
a/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java
+++
b/src/test/java/org/apache/commons/dbcp2/cpdsadapter/TestDriverAdapterCPDS.java
@@ -38,6 +38,7 @@ import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.sql.DataSource;
+import org.apache.commons.dbcp2.Constants;
import org.apache.commons.dbcp2.datasources.SharedPoolDataSource;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -155,8 +156,8 @@ public class TestDriverAdapterCPDS {
// Supply correct value in connection properties
// This will overwrite field value
final Properties properties = new Properties();
- properties.put("user", "foo");
- properties.put("password", pcds.getPassword());
+ properties.put(Constants.KEY_USER, "foo");
+ properties.put(Constants.KEY_PASSWORD, pcds.getPassword());
pcds.setConnectionProperties(properties);
pcds.getPooledConnection().close();
assertEquals("foo", pcds.getUser());
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 6042476..19ff91c 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnection.java
@@ -34,6 +34,7 @@ import javax.transaction.TransactionManager;
import javax.transaction.xa.XAResource;
import org.apache.commons.dbcp2.ConnectionFactory;
+import org.apache.commons.dbcp2.Constants;
import org.apache.commons.dbcp2.DelegatingConnection;
import org.apache.commons.dbcp2.DriverConnectionFactory;
import org.apache.commons.dbcp2.PoolableConnection;
@@ -65,8 +66,8 @@ public class TestManagedConnection {
// create a driver connection factory
final Properties properties = new Properties();
- properties.setProperty("user", "userName");
- properties.setProperty("password", "password");
+ properties.setProperty(Constants.KEY_USER, "userName");
+ properties.setProperty(Constants.KEY_PASSWORD, "password");
final ConnectionFactory connectionFactory = new
DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver",
properties);
// wrap it with a LocalXAConnectionFactory
diff --git
a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnectionCachedState.java
b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnectionCachedState.java
index 02a3d72..cf7c442 100644
---
a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnectionCachedState.java
+++
b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedConnectionCachedState.java
@@ -29,6 +29,7 @@ import javax.transaction.TransactionManager;
import javax.transaction.xa.XAException;
import org.apache.commons.dbcp2.ConnectionFactory;
+import org.apache.commons.dbcp2.Constants;
import org.apache.commons.dbcp2.DriverConnectionFactory;
import org.apache.commons.dbcp2.PoolableConnection;
import org.apache.commons.dbcp2.PoolableConnectionFactory;
@@ -61,8 +62,8 @@ public class TestManagedConnectionCachedState {
// create a driver connection factory
final Properties properties = new Properties();
- properties.setProperty("user", "userName");
- properties.setProperty("password", "password");
+ properties.setProperty(Constants.KEY_USER, "userName");
+ properties.setProperty(Constants.KEY_PASSWORD, "password");
final ConnectionFactory connectionFactory = new
DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver",
properties);
// wrap it with a LocalXAConnectionFactory
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 4628956..09e733b 100644
--- a/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
+++ b/src/test/java/org/apache/commons/dbcp2/managed/TestManagedDataSource.java
@@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.dbcp2.ConnectionFactory;
+import org.apache.commons.dbcp2.Constants;
import org.apache.commons.dbcp2.DelegatingConnection;
import org.apache.commons.dbcp2.DriverConnectionFactory;
import org.apache.commons.dbcp2.PoolableConnection;
@@ -66,8 +67,8 @@ public class TestManagedDataSource extends TestConnectionPool
{
// create a driver connection factory
final Properties properties = new Properties();
- properties.setProperty("user", "userName");
- properties.setProperty("password", "password");
+ properties.setProperty(Constants.KEY_USER, "userName");
+ properties.setProperty(Constants.KEY_PASSWORD, "password");
final ConnectionFactory connectionFactory = new
DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver",
properties);
// wrap it with a LocalXAConnectionFactory
diff --git
a/src/test/java/org/apache/commons/dbcp2/managed/TestPoolableManagedConnection.java
b/src/test/java/org/apache/commons/dbcp2/managed/TestPoolableManagedConnection.java
index 056cceb..7c1d94b 100644
---
a/src/test/java/org/apache/commons/dbcp2/managed/TestPoolableManagedConnection.java
+++
b/src/test/java/org/apache/commons/dbcp2/managed/TestPoolableManagedConnection.java
@@ -30,6 +30,7 @@ import java.util.Properties;
import javax.transaction.TransactionManager;
import org.apache.commons.dbcp2.ConnectionFactory;
+import org.apache.commons.dbcp2.Constants;
import org.apache.commons.dbcp2.DriverConnectionFactory;
import org.apache.commons.dbcp2.PoolableConnection;
import org.apache.commons.dbcp2.PoolableConnectionFactory;
@@ -58,8 +59,8 @@ public class TestPoolableManagedConnection {
// create a driver connection factory
final Properties properties = new Properties();
- properties.setProperty("user", "userName");
- properties.setProperty("password", "password");
+ properties.setProperty(Constants.KEY_USER, "userName");
+ properties.setProperty(Constants.KEY_PASSWORD, "password");
final ConnectionFactory connectionFactory = new
DriverConnectionFactory(new TesterDriver(), "jdbc:apache:commons:testdriver",
properties);
// wrap it with a LocalXAConnectionFactory