Skip to content

Commit

Permalink
fixed warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
alexradzin committed May 6, 2024
1 parent 7e8abd2 commit d4e2028
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/firebolt/jdbc/client/FireboltClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand All @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ protected Optional<ResultSet> execute(List<StatementInfoWrapper> statements) thr
return resultSet;
}

@SuppressWarnings("java:S2139") // TODO: Exceptions should be either logged or rethrown but not both
private Optional<ResultSet> execute(StatementInfoWrapper statementInfoWrapper, boolean verifyNotCancelled, boolean isStandardSql) throws SQLException {
createValidator(statementInfoWrapper.getInitialStatement(), connection).validate(statementInfoWrapper.getInitialStatement());
ResultSet resultSet = null;
Expand Down Expand Up @@ -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);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/firebolt/jdbc/type/date/SqlDateUtil.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/firebolt/jdbc/util/CloseableUtil.java
Original file line number Diff line number Diff line change
@@ -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());
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/firebolt/jdbc/util/LoggerUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/com/firebolt/jdbc/util/PropertyUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/firebolt/jdbc/util/VersionUtil.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.firebolt.jdbc.util;

import lombok.CustomLog;
import lombok.experimental.UtilityClass;

import java.io.File;
import java.io.FileInputStream;
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;
Expand Down

0 comments on commit d4e2028

Please sign in to comment.