Repository: groovy Updated Branches: refs/heads/GROOVY_2_4_X 130e1a272 -> 687a27ef8
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/f4fbe350 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/f4fbe350 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/f4fbe350 Branch: refs/heads/GROOVY_2_4_X Commit: f4fbe350b80b7332473f9176776af51a333f1d1e Parents: 130e1a2 Author: John Wagenleitner <[email protected]> Authored: Mon Mar 5 18:58:52 2018 -0800 Committer: John Wagenleitner <[email protected]> Committed: Mon Mar 5 19:08:43 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/f4fbe350/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 68aa026..ceaf8b2 100644 --- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java +++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java @@ -597,14 +597,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);
