Permalink
Browse files

refactor: wrap more log statements with isLoggable check

  • Loading branch information...
vlsi committed Feb 18, 2017
1 parent 8b50cfe commit 07d225ec1028d945533d5023702b3865aee54ad6
@@ -450,7 +450,9 @@ private void doAuthentication(PGStream pgStream, String host, String user, Prope
case AUTH_REQ_CRYPT: {
byte[] salt = pgStream.receive(2);

LOGGER.log(Level.FINEST, " <=BE AuthenticationReqCrypt(salt=''{0}'')", new String(salt, "US-ASCII"));
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, " <=BE AuthenticationReqCrypt(salt=''{0}'')", new String(salt, "US-ASCII"));
}

if (password == null) {
throw new PSQLException(
@@ -461,7 +463,9 @@ private void doAuthentication(PGStream pgStream, String host, String user, Prope

byte[] encodedResult = UnixCrypt.crypt(salt, password.getBytes("UTF-8"));

LOGGER.log(Level.FINEST, " FE=> Password(crypt=''{0}'')", new String(encodedResult, "US-ASCII"));
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, " FE=> Password(crypt=''{0}'')", new String(encodedResult, "US-ASCII"));
}

pgStream.sendChar('p');
pgStream.sendInteger4(4 + encodedResult.length + 1);
@@ -474,7 +478,9 @@ private void doAuthentication(PGStream pgStream, String host, String user, Prope

case AUTH_REQ_MD5: {
byte[] md5Salt = pgStream.receive(4);
LOGGER.log(Level.FINEST, " <=BE AuthenticationReqMD5(salt={0})", Utils.toHexString(md5Salt));
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, " <=BE AuthenticationReqMD5(salt={0})", Utils.toHexString(md5Salt));
}

if (password == null) {
throw new PSQLException(
@@ -486,7 +492,9 @@ private void doAuthentication(PGStream pgStream, String host, String user, Prope
byte[] digest =
MD5Digest.encode(user.getBytes("UTF-8"), password.getBytes("UTF-8"), md5Salt);

LOGGER.log(Level.FINEST, " FE=> Password(md5digest={0})", new String(digest, "US-ASCII"));
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, " FE=> Password(md5digest={0})", new String(digest, "US-ASCII"));
}

pgStream.sendChar('p');
pgStream.sendInteger4(4 + digest.length + 1);
@@ -2405,7 +2405,9 @@ private SQLException receiveErrorResponse() throws IOException {
EncodingPredictor.DecodeResult totalMessage = pgStream.receiveErrorString(elen - 4);
ServerErrorMessage errorMsg = new ServerErrorMessage(totalMessage);

LOGGER.log(Level.FINEST, " <=BE ErrorMessage({0})", errorMsg.toString());
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, " <=BE ErrorMessage({0})", errorMsg.toString());
}

PSQLException error = new PSQLException(errorMsg);
if (transactionFailCause == null) {
@@ -2420,7 +2422,9 @@ private SQLWarning receiveNoticeResponse() throws IOException {
int nlen = pgStream.receiveInteger4();
ServerErrorMessage warnMsg = new ServerErrorMessage(pgStream.receiveString(nlen - 4));

LOGGER.log(Level.FINEST, " <=BE NoticeResponse({0})", warnMsg.toString());
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, " <=BE NoticeResponse({0})", warnMsg.toString());
}

return new PSQLWarning(warnMsg);
}
@@ -1281,10 +1281,13 @@ public void refreshRow() throws SQLException {
selectSQL.append(" and ");
}
}
connection.getLogger().log(Level.FINE, "selecting {0}", selectSQL.toString());
String sqlText = selectSQL.toString();
if (connection.getLogger().isLoggable(Level.FINE)) {
connection.getLogger().log(Level.FINE, "selecting {0}", sqlText);
}
// because updateable result sets do not yet support binary transfers we must request refresh
// with updateable result set to get field data in correct format
selectStatement = connection.prepareStatement(selectSQL.toString(),
selectStatement = connection.prepareStatement(sqlText,
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);


@@ -1358,8 +1361,11 @@ public synchronized void updateRow() throws SQLException {
}
}

connection.getLogger().log(Level.FINE, "updating {0}", updateSQL.toString());
updateStatement = connection.prepareStatement(updateSQL.toString());
String sqlText = updateSQL.toString();
if (connection.getLogger().isLoggable(Level.FINE)) {
connection.getLogger().log(Level.FINE, "updating {0}", sqlText);
}
updateStatement = connection.prepareStatement(sqlText);

int i = 0;
Iterator<Object> iterator = updateValues.values().iterator();

0 comments on commit 07d225e

Please sign in to comment.