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 33ddd60 Deduplicate internals. 33ddd60 is described below commit 33ddd6066e68aaa71d78d240a058dff24f56844a Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Sun Jun 6 11:32:26 2021 -0400 Deduplicate internals. --- .../dbcp2/datasources/PooledConnectionAndInfo.java | 23 ++++------------------ .../commons/dbcp2/datasources/UserPassKey.java | 2 +- 2 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/PooledConnectionAndInfo.java b/src/main/java/org/apache/commons/dbcp2/datasources/PooledConnectionAndInfo.java index 6992dd9..8e16c59 100644 --- a/src/main/java/org/apache/commons/dbcp2/datasources/PooledConnectionAndInfo.java +++ b/src/main/java/org/apache/commons/dbcp2/datasources/PooledConnectionAndInfo.java @@ -19,8 +19,6 @@ package org.apache.commons.dbcp2.datasources; import javax.sql.PooledConnection; -import org.apache.commons.dbcp2.Utils; - /** * Immutable poolable object holding a {@link PooledConnection} along with the user name and password used to create the * connection. @@ -28,9 +26,8 @@ import org.apache.commons.dbcp2.Utils; * @since 2.0 */ final class PooledConnectionAndInfo { + private final PooledConnection pooledConnection; - private final char[] userPassword; - private final String userName; private final UserPassKey upKey; /** @@ -40,15 +37,13 @@ final class PooledConnectionAndInfo { */ PooledConnectionAndInfo(final PooledConnection pc, final String userName, final char[] userPassword) { this.pooledConnection = pc; - this.userName = userName; - this.userPassword = userPassword; this.upKey = new UserPassKey(userName, userPassword); } /** * Gets the pooled connection. * - * @return + * @return the pooled connection. */ PooledConnection getPooledConnection() { return pooledConnection; @@ -64,17 +59,7 @@ final class PooledConnectionAndInfo { * @return value of password. */ String getPassword() { - return Utils.toString(userPassword); - } - - /** - * Gets the value of password. - * - * @return value of password. - * @since 2.4.0 - */ - char[] getPasswordCharArray() { - return userPassword; + return upKey.getPassword(); } /** @@ -83,6 +68,6 @@ final class PooledConnectionAndInfo { * @return value of userName. */ String getUsername() { - return userName; + return upKey.getUserName(); } } 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 0149655..a64f70b 100644 --- a/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java +++ b/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java @@ -95,7 +95,7 @@ class UserPassKey implements Serializable { * @return value of password. */ char[] getPasswordCharArray() { - return userPassword; + return userPassword == null ? userPassword : userPassword.clone(); } /**