You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/02/08 04:12:34 UTC

[10/11] groovy git commit: GROOVY-8068: improper logging in groovy.sql.Sql (closes #491)

GROOVY-8068: improper logging in groovy.sql.Sql (closes #491)


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

Branch: refs/heads/parrot
Commit: 01fdb705c4ca0737949c4fd323b62736c27716a8
Parents: 59a36cf
Author: paulk <pa...@asert.com.au>
Authored: Tue Feb 7 18:31:02 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Tue Feb 7 18:35:39 2017 +1000

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


http://git-wip-us.apache.org/repos/asf/groovy/blob/01fdb705/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 7816dec..b115ed8 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
@@ -578,17 +578,26 @@ public class Sql {
 
         Object url = sqlArgs.remove("url");
         Connection connection;
+        LOG.fine("url = " + url);
         if (props != null) {
-            System.err.println("url = " + url);
-            System.err.println("props = " + props);
-            connection = DriverManager.getConnection(url.toString(), new Properties(props));
+            Properties propsCopy = new Properties(props);
+            connection = DriverManager.getConnection(url.toString(), propsCopy);
+            if (propsCopy.containsKey("password")) {
+                // don't log the password
+                propsCopy = new Properties(propsCopy);
+                propsCopy.setProperty("password", "***");
+            }
+            LOG.fine("props = " + propsCopy);
         } else if (sqlArgs.containsKey("user")) {
             Object user = sqlArgs.remove("user");
+            LOG.fine("user = " + user);
             Object password = sqlArgs.remove("password");
+            LOG.fine("password = " + (password == null ? "null" : "***"));
             connection = DriverManager.getConnection(url.toString(),
                     (user == null ? null : user.toString()),
                     (password == null ? null : password.toString()));
         } else {
+            LOG.fine("No user/password specified");
             connection = DriverManager.getConnection(url.toString());
         }