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:03:39 UTC

[2/2] groovy git commit: only perform the extra work if logging level is enabled

only perform the extra work if logging level is enabled


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

Branch: refs/heads/master
Commit: 8a33815fd8176475eacadaf0ebe165b528ef4c6c
Parents: aef360a
Author: John Wagenleitner <jw...@apache.org>
Authored: Mon Mar 5 18:59:30 2018 -0800
Committer: John Wagenleitner <jw...@apache.org>
Committed: Mon Mar 5 18:59:30 2018 -0800

----------------------------------------------------------------------
 .../groovy-sql/src/main/java/groovy/sql/Sql.java | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/8a33815f/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 4c86798..a554644 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
@@ -47,6 +47,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -590,14 +591,16 @@ public class Sql {
         LOG.fine("url = " + url);
         if (props != null) {
             connection = DriverManager.getConnection(url.toString(), props);
-            if (!props.containsKey("password")) {
-                LOG.fine("props = " + props);
-            } else {
-                // don't log the password
-                Properties propsCopy = new Properties();
-                propsCopy.putAll(props);
-                propsCopy.setProperty("password", "***");
-                LOG.fine("props = " + propsCopy);
+            if (LOG.isLoggable(Level.FINE)) {
+                if (!props.containsKey("password")) {
+                    LOG.fine("props = " + props);
+                } else {
+                    // don't log the password
+                    Properties propsCopy = new Properties();
+                    propsCopy.putAll(props);
+                    propsCopy.setProperty("password", "***");
+                    LOG.fine("props = " + propsCopy);
+                }
             }
         } else if (sqlArgs.containsKey("user")) {
             Object user = sqlArgs.remove("user");