Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X fd7601dc4 -> d03d70e27
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/d03d70e2 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d03d70e2 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d03d70e2 Branch: refs/heads/GROOVY_2_6_X Commit: d03d70e273e683ed0f18258003ba7f13dbbfaab7 Parents: 1c45abe Author: John Wagenleitner <[email protected]> Authored: Mon Mar 5 18:59:30 2018 -0800 Committer: John Wagenleitner <[email protected]> Committed: Mon Mar 5 19:04:59 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/d03d70e2/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");
