groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jwagenleit...@apache.org
Subject [1/2] groovy git commit: GROOVY-8422: Incorrect properties copy in Sql.newInstance (closes #671)
Date Tue, 06 Mar 2018 03:03:38 GMT
Repository: groovy
Updated Branches:
  refs/heads/master 09d7eee74 -> 8a33815fd


GROOVY-8422: Incorrect properties copy in Sql.newInstance (closes #671)

The provided Properties should be passed to the DriverManager as-is.
A copy is only needed when changes are made to the provided Properties
in order to mask sensitive information for logging purposes.


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/aef360a0
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/aef360a0
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/aef360a0

Branch: refs/heads/master
Commit: aef360a09f745078433285d7a3115d34d74ba4fd
Parents: 09d7eee
Author: John Wagenleitner <jwagenleitner@apache.org>
Authored: Mon Mar 5 18:58:52 2018 -0800
Committer: John Wagenleitner <jwagenleitner@apache.org>
Committed: Mon Mar 5 18:58:52 2018 -0800

----------------------------------------------------------------------
 .../groovy-sql/src/main/java/groovy/sql/Sql.java        | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/aef360a0/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
----------------------------------------------------------------------
diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
index 9d92043..4c86798 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
@@ -589,14 +589,16 @@ public class Sql {
         Connection connection;
         LOG.fine("url = " + url);
         if (props != null) {
-            Properties propsCopy = new Properties(props);
-            connection = DriverManager.getConnection(url.toString(), propsCopy);
-            if (propsCopy.containsKey("password")) {
+            connection = DriverManager.getConnection(url.toString(), props);
+            if (!props.containsKey("password")) {
+                LOG.fine("props = " + props);
+            } else {
                 // don't log the password
-                propsCopy = new Properties(propsCopy);
+                Properties propsCopy = new Properties();
+                propsCopy.putAll(props);
                 propsCopy.setProperty("password", "***");
+                LOG.fine("props = " + propsCopy);
             }
-            LOG.fine("props = " + propsCopy);
         } else if (sqlArgs.containsKey("user")) {
             Object user = sqlArgs.remove("user");
             LOG.fine("user = " + user);


Mime
View raw message