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 2022/11/30 16:14:51 UTC

[commons-dbcp] branch master updated: Lookup key in map only once

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 e3e838f6 Lookup key in map only once
e3e838f6 is described below

commit e3e838f6186e005294ac02471b2ce6a8d82b667d
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Nov 30 11:14:46 2022 -0500

    Lookup key in map only once
---
 .../apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

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 45140185..6f56f645 100644
--- a/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
+++ b/src/main/java/org/apache/commons/dbcp2/cpdsadapter/DriverAdapterCPDS.java
@@ -552,11 +552,13 @@ public class DriverAdapterCPDS implements ConnectionPoolDataSource, Referenceabl
         assertInitializationAllowed();
         connectionProperties = props;
         if (connectionProperties != null) {
-            if (connectionProperties.containsKey(Constants.KEY_USER)) {
-                setUser(connectionProperties.getProperty(Constants.KEY_USER));
+            final String user = connectionProperties.getProperty(Constants.KEY_USER);
+            if (user != null) {
+                setUser(user);
             }
-            if (connectionProperties.containsKey(Constants.KEY_PASSWORD)) {
-                setPassword(connectionProperties.getProperty(Constants.KEY_PASSWORD));
+            final String password = connectionProperties.getProperty(Constants.KEY_PASSWORD);
+            if (password != null) {
+                setPassword(password);
             }
         }
     }