You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by jw...@apache.org on 2018/03/06 03:05:59 UTC
[2/2] groovy git commit: GROOVY-8422: Incorrect properties copy in
Sql.newInstance (closes #671)
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/1c45abe1
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/1c45abe1
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/1c45abe1
Branch: refs/heads/GROOVY_2_6_X
Commit: 1c45abe109448550a73f07eb8382c720d0de9264
Parents: fd7601d
Author: John Wagenleitner <jw...@apache.org>
Authored: Mon Mar 5 18:58:52 2018 -0800
Committer: John Wagenleitner <jw...@apache.org>
Committed: Mon Mar 5 19:04:59 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/1c45abe1/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);