Permalink
Browse files

perf: add guards around debug log statements

Some debug log statements that construct messages using string
concatenation are not surrounded by guard statements. This results in
unnecessary allocation when debug logging is not enabled.

Add guards around debug log statements where necessary.

closes #469
  • Loading branch information...
marschall authored and vlsi committed Dec 25, 2015
1 parent ea4cadd commit d77aa4103bc4388840d17123afc9266412780a76
@@ -149,7 +149,8 @@ private Properties loadDefaultProperties() throws IOException {
return merged; // Give up on finding defaults.
}
logger.debug("Loading driver configuration via classloader " + cl);
if (logger.logDebug())
logger.debug("Loading driver configuration via classloader " + cl);
// When loading the driver config files we don't want settings found
// in later files in the classpath to override settings specified in
@@ -164,7 +165,8 @@ private Properties loadDefaultProperties() throws IOException {
for (int i=urls.size()-1; i>=0; i--) {
URL url = urls.get(i);
logger.debug("Loading driver configuration from: " + url);
if (logger.logDebug())
logger.debug("Loading driver configuration from: " + url);
InputStream is = url.openStream();
merged.load(is);
is.close();
@@ -267,12 +269,14 @@ private Properties loadDefaultProperties() throws IOException {
// parse URL and add more properties
if ((props = parseURL(url, props)) == null)
{
logger.debug("Error in url: " + url);
if (logger.logDebug())
logger.debug("Error in url: " + url);
return null;
}
try
{
logger.debug("Connecting with URL: " + url);
if (logger.logDebug())
logger.debug("Connecting with URL: " + url);
// Enforce login timeout, if specified, by running the connection
// attempt in a separate thread. If we hit the timeout without the
@@ -660,7 +664,8 @@ private static long timeout(Properties props)
} catch (NumberFormatException e) {
// Log level isn't set yet, so this doesn't actually
// get printed.
logger.debug("Couldn't parse loginTimeout value: " + timeout);
if (logger.logDebug())
logger.debug("Couldn't parse loginTimeout value: " + timeout);
}
}
return (long) DriverManager.getLoginTimeout() * 1000;
@@ -559,7 +559,8 @@ else if (areq == AUTH_REQ_GSS && !gsslib.equals("sspi"))
logger);
useSSPI = sspiClient.isSSPISupported();
logger.debug("SSPI support detected: " + useSSPI);
if (logger.logDebug())
logger.debug("SSPI support detected: " + useSSPI);
if (!useSSPI) {
/* No need to dispose() if no SSPI used */
@@ -570,7 +571,8 @@ else if (areq == AUTH_REQ_GSS && !gsslib.equals("sspi"))
PSQLState.CONNECTION_UNABLE_TO_CONNECT);
}
logger.debug("Using SSPI: " + useSSPI + ", gsslib="+gsslib+" and SSPI support detected");
if (logger.logDebug())
logger.debug("Using SSPI: " + useSSPI + ", gsslib="+gsslib+" and SSPI support detected");
}
if (useSSPI)
@@ -137,7 +137,8 @@ public void startSSPI() throws SQLException, IOException {
*/
final String securityPackage = enableNegotiate ? "negotiate" : "kerberos";
logger.debug("Beginning SSPI/Kerberos negotiation with SSPI package: " + securityPackage);
if (logger.logDebug())
logger.debug("Beginning SSPI/Kerberos negotiation with SSPI package: " + securityPackage);
try {
/*

0 comments on commit d77aa41

Please sign in to comment.