diff --git a/src/main/java/com/firebolt/jdbc/client/FireboltClient.java b/src/main/java/com/firebolt/jdbc/client/FireboltClient.java index e1b361792..ffa7d43e7 100644 --- a/src/main/java/com/firebolt/jdbc/client/FireboltClient.java +++ b/src/main/java/com/firebolt/jdbc/client/FireboltClient.java @@ -165,6 +165,7 @@ protected String getResponseAsString(Response response) throws FireboltException return response.body().string(); } + @SuppressWarnings("java:S2139") // TODO: Exceptions should be either logged or rethrown but not both private String extractErrorMessage(Response response, boolean isCompress) throws FireboltException { byte[] entityBytes; try { diff --git a/src/main/java/com/firebolt/jdbc/resultset/FireboltResultSet.java b/src/main/java/com/firebolt/jdbc/resultset/FireboltResultSet.java index 15e66e79b..2099b5e70 100644 --- a/src/main/java/com/firebolt/jdbc/resultset/FireboltResultSet.java +++ b/src/main/java/com/firebolt/jdbc/resultset/FireboltResultSet.java @@ -86,6 +86,7 @@ public class FireboltResultSet extends JdbcBase implements ResultSet { private String lastReadValue = null; + @SuppressWarnings("java:S2139") // TODO: Exceptions should be either logged or rethrown but not both public FireboltResultSet(InputStream is, String tableName, String dbName, int bufferSize, boolean isCompressed, FireboltStatement statement, boolean logResultSet) throws SQLException { log.fine("Creating resultSet..."); @@ -110,8 +111,8 @@ public FireboltResultSet(InputStream is, String tableName, String dbName, int bu columns = next() ? getColumns(fields, currentLine) : new ArrayList<>(); resultSetMetaData = new FireboltResultSetMetaData(dbName, tableName, columns); } catch (Exception e) { - log.log(Level.SEVERE, "Could not create ResultSet: " + e.getMessage(), e); - throw new FireboltException("Cannot read response from DB: error while creating ResultSet ", e); + log.log(Level.SEVERE, e, () -> "Could not create ResultSet: " + e.getMessage()); + throw new FireboltException("Cannot read response from DB: error while creating ResultSet", e); } log.fine("ResultSet created"); } diff --git a/src/main/java/com/firebolt/jdbc/service/FireboltAuthenticationService.java b/src/main/java/com/firebolt/jdbc/service/FireboltAuthenticationService.java index 7ac07132e..8fe3acac5 100644 --- a/src/main/java/com/firebolt/jdbc/service/FireboltAuthenticationService.java +++ b/src/main/java/com/firebolt/jdbc/service/FireboltAuthenticationService.java @@ -1,11 +1,9 @@ package com.firebolt.jdbc.service; import com.firebolt.jdbc.client.authentication.FireboltAuthenticationClient; -import com.firebolt.jdbc.client.config.socket.SocketUtil; import com.firebolt.jdbc.connection.FireboltConnectionTokens; import com.firebolt.jdbc.connection.settings.FireboltProperties; import com.firebolt.jdbc.exception.FireboltException; -import lombok.CustomLog; import lombok.EqualsAndHashCode; import lombok.RequiredArgsConstructor; import net.jodah.expiringmap.ExpiringMap; @@ -33,6 +31,7 @@ public class FireboltAuthenticationService { private static final String ERROR_MESSAGE_FROM_SERVER = "Failed to connect to Firebolt with the error from the server: %s, see logs for more info."; private final FireboltAuthenticationClient fireboltAuthenticationClient; + @SuppressWarnings("java:S2139") // TODO: Exceptions should be either logged or rethrown but not both public FireboltConnectionTokens getConnectionTokens(String host, FireboltProperties loginProperties) throws FireboltException { try { ConnectParams connectionParams = new ConnectParams(host, loginProperties.getPrincipal(), loginProperties.getSecret()); diff --git a/src/main/java/com/firebolt/jdbc/statement/FireboltStatement.java b/src/main/java/com/firebolt/jdbc/statement/FireboltStatement.java index 225a17b63..a73fb4ddf 100644 --- a/src/main/java/com/firebolt/jdbc/statement/FireboltStatement.java +++ b/src/main/java/com/firebolt/jdbc/statement/FireboltStatement.java @@ -100,6 +100,7 @@ protected Optional execute(List statements) thr return resultSet; } + @SuppressWarnings("java:S2139") // TODO: Exceptions should be either logged or rethrown but not both private Optional execute(StatementInfoWrapper statementInfoWrapper, boolean verifyNotCancelled, boolean isStandardSql) throws SQLException { createValidator(statementInfoWrapper.getInitialStatement(), connection).validate(statementInfoWrapper.getInitialStatement()); ResultSet resultSet = null; @@ -166,7 +167,7 @@ public void cancel() throws SQLException { } String statementLabel = runningStatementLabel; if (statementLabel != null) { - log.info("Cancelling statement with label " + statementLabel); + log.log(Level.INFO, "Cancelling statement with label {0}", statementLabel); abortStatementRunningOnFirebolt(statementLabel); } } diff --git a/src/main/java/com/firebolt/jdbc/type/date/SqlDateUtil.java b/src/main/java/com/firebolt/jdbc/type/date/SqlDateUtil.java index 1595c51fb..d6d8b1347 100644 --- a/src/main/java/com/firebolt/jdbc/type/date/SqlDateUtil.java +++ b/src/main/java/com/firebolt/jdbc/type/date/SqlDateUtil.java @@ -1,7 +1,6 @@ package com.firebolt.jdbc.type.date; import com.firebolt.jdbc.CheckedBiFunction; -import lombok.CustomLog; import lombok.experimental.UtilityClass; import java.sql.Date; diff --git a/src/main/java/com/firebolt/jdbc/util/CloseableUtil.java b/src/main/java/com/firebolt/jdbc/util/CloseableUtil.java index 39de66c2e..c09886fda 100644 --- a/src/main/java/com/firebolt/jdbc/util/CloseableUtil.java +++ b/src/main/java/com/firebolt/jdbc/util/CloseableUtil.java @@ -1,13 +1,12 @@ package com.firebolt.jdbc.util; +import lombok.experimental.UtilityClass; + import java.io.Closeable; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; -import lombok.CustomLog; -import lombok.experimental.UtilityClass; - @UtilityClass public class CloseableUtil { private static final Logger log = Logger.getLogger(CloseableUtil.class.getName()); diff --git a/src/main/java/com/firebolt/jdbc/util/LoggerUtil.java b/src/main/java/com/firebolt/jdbc/util/LoggerUtil.java index b25966a35..4cb06ea2d 100644 --- a/src/main/java/com/firebolt/jdbc/util/LoggerUtil.java +++ b/src/main/java/com/firebolt/jdbc/util/LoggerUtil.java @@ -22,14 +22,14 @@ public class LoggerUtil { private static final Logger log = Logger.getLogger(LoggerUtil.class.getName()); private Logger initRootLogger() { - Logger root = Logger.getLogger(FireboltDriver.class.getPackageName()); + Logger parent = Logger.getLogger(FireboltDriver.class.getPackageName()); if (slf4jAvailable) { - synchronized (root) { - root.addHandler(new SLF4JBridgeHandler()); - root.setLevel(Level.ALL); + synchronized (LoggerUtil.class) { + parent.addHandler(new SLF4JBridgeHandler()); + parent.setLevel(Level.ALL); } } - return root; + return parent; } public static Logger getRootLogger() { diff --git a/src/main/java/com/firebolt/jdbc/util/PropertyUtil.java b/src/main/java/com/firebolt/jdbc/util/PropertyUtil.java index 74fd93b52..bf6a382dd 100644 --- a/src/main/java/com/firebolt/jdbc/util/PropertyUtil.java +++ b/src/main/java/com/firebolt/jdbc/util/PropertyUtil.java @@ -2,7 +2,6 @@ import com.firebolt.jdbc.connection.settings.FireboltProperties; import com.firebolt.jdbc.connection.settings.FireboltSessionProperty; -import lombok.CustomLog; import lombok.experimental.UtilityClass; import java.sql.DriverPropertyInfo; diff --git a/src/main/java/com/firebolt/jdbc/util/VersionUtil.java b/src/main/java/com/firebolt/jdbc/util/VersionUtil.java index 4c70c905d..5e9b1c979 100644 --- a/src/main/java/com/firebolt/jdbc/util/VersionUtil.java +++ b/src/main/java/com/firebolt/jdbc/util/VersionUtil.java @@ -1,6 +1,5 @@ package com.firebolt.jdbc.util; -import lombok.CustomLog; import lombok.experimental.UtilityClass; import java.io.File; @@ -8,7 +7,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; -import java.util.Arrays; import java.util.Enumeration; import java.util.Properties; import java.util.jar.Attributes.Name;