Skip to content

Commit

Permalink
removed redundant and updated versions of some dependencies (#261)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexradzin authored Aug 16, 2023
1 parent 3c2e7e2 commit 0e17fe3
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 127 deletions.
32 changes: 16 additions & 16 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import java.util.jar.JarFile
plugins {
id 'java'
id 'jacoco'
id "org.sonarqube" version "4.0.0.2929"
id "org.sonarqube" version "4.3.0.3225"
id 'maven-publish'
id 'com.github.johnrengelman.shadow' version '8.0.0'
}
Expand Down Expand Up @@ -56,35 +56,35 @@ sourceSets {

}
dependencies {
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.guava:guava:31.1-jre'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
implementation 'commons-codec:commons-codec:1.15'
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
implementation 'net.jodah:expiringmap:0.5.10'
implementation 'org.apache.commons:commons-lang3:3.13.0'
implementation 'org.apache.commons:commons-text:1.10.0'
implementation 'org.lz4:lz4-java:1.8.0'
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
implementation 'javax.xml.bind:jaxb-api:2.3.1'

implementation fileTree(dir: 'libs', includes: ['*.jar'])
compileOnly 'org.slf4j:slf4j-api:2.0.7'

compileOnly 'org.projectlombok:lombok:1.18.26'
annotationProcessor 'org.projectlombok:lombok:1.18.26'
testCompileOnly 'org.projectlombok:lombok:1.18.26'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.26'
compileOnly 'org.slf4j:slf4j-api:2.0.7'
compileOnly 'org.projectlombok:lombok:1.18.28'
annotationProcessor 'org.projectlombok:lombok:1.18.28'
testCompileOnly 'org.projectlombok:lombok:1.18.28'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.28'

testImplementation 'ch.qos.logback:logback-classic:1.4.9'
testImplementation 'org.mockito:mockito-junit-jupiter:4.11.0'
testImplementation 'org.mockito:mockito-core:4.11.0'
testImplementation 'org.mockito:mockito-inline:4.11.0'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.2'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.0'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.10.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.0'
testImplementation 'org.junit-pioneer:junit-pioneer:1.9.1'
testImplementation 'org.hamcrest:hamcrest-library:2.2'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
testImplementation 'com.squareup.okhttp3:okhttp-tls:4.10.0'
testImplementation 'io.zonky.test:embedded-postgres:2.0.3'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.11.0'
testImplementation 'com.squareup.okhttp3:okhttp-tls:4.11.0'
testImplementation 'io.zonky.test:embedded-postgres:2.0.4'
testCompileOnly 'org.slf4j:slf4j-api:2.0.7'
testCommonImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testImplementation sourceSets.testCommon.output
Expand Down
19 changes: 10 additions & 9 deletions src/integrationTest/java/integration/IntegrationTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package integration;

import com.firebolt.jdbc.client.HttpClientConfig;
import lombok.CustomLog;
import lombok.SneakyThrows;
import org.junit.jupiter.api.TestInstance;

import java.io.InputStream;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
import java.sql.Connection;
Expand All @@ -8,13 +14,7 @@
import java.sql.Statement;
import java.util.Optional;

import org.junit.jupiter.api.TestInstance;

import com.firebolt.jdbc.client.HttpClientConfig;
import com.google.common.io.Resources;

import lombok.CustomLog;
import lombok.SneakyThrows;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@CustomLog
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
Expand Down Expand Up @@ -58,8 +58,9 @@ protected void executeStatementFromFile(String path) {

@SneakyThrows
protected void executeStatementFromFile(String path, String engine) {
try (Connection connection = createConnection(engine); Statement statement = connection.createStatement()) {
String sql = Resources.toString(IntegrationTest.class.getResource(path), StandardCharsets.UTF_8);
try (Connection connection = createConnection(engine); Statement statement = connection.createStatement(); InputStream is = IntegrationTest.class.getResourceAsStream(path)) {
assertNotNull(is);
String sql = new String(is.readAllBytes(), StandardCharsets.UTF_8);
statement.execute(sql);
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/com/firebolt/jdbc/client/UsageTrackerUtil.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package com.firebolt.jdbc.client;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.firebolt.jdbc.util.VersionUtil;
import com.google.common.collect.ImmutableMap;

import lombok.CustomLog;
import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

@CustomLog
@UtilityClass
public class UsageTrackerUtil {

public static final Map<String, String> CLIENT_MAP = ImmutableMap.of("Tableau", "com.tableau", "Looker",
"com.looker", "Calcite", "org.apache.calcite", "Metabase", "metabase");
public static final Map<String, String> CLIENT_MAP = Map.of(
"Tableau", "com.tableau",
"Looker", "com.looker",
"Calcite", "org.apache.calcite",
"Metabase", "metabase");

public static final Map<String, String> DRIVER_MAP = ImmutableMap.of();
public static final Map<String, String> DRIVER_MAP = Map.of();

private static String getVersionForClass(String name) {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package com.firebolt.jdbc.client.authentication;

import java.io.IOException;

import org.apache.commons.lang3.StringUtils;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.firebolt.jdbc.client.FireboltClient;
import com.firebolt.jdbc.client.authentication.response.FireboltAuthenticationResponse;
import com.firebolt.jdbc.connection.FireboltConnection;
import com.firebolt.jdbc.connection.FireboltConnectionTokens;
import com.firebolt.jdbc.exception.FireboltException;

import lombok.CustomLog;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

@CustomLog
public class FireboltAuthenticationClient extends FireboltClient {

Expand Down Expand Up @@ -54,16 +51,16 @@ public FireboltConnectionTokens postConnectionTokens(String host, String user, S
}

private void logToken(FireboltAuthenticationResponse connectionTokens) {

if (!StringUtils.isEmpty(connectionTokens.getAccessToken())) {
log.debug("Retrieved access_token");
logIfPresent(connectionTokens.getAccessToken(), "Retrieved access_token");
logIfPresent(connectionTokens.getRefreshToken(), "Retrieved refresh_token");
if (connectionTokens.getExpiresIn() >=- 0) {
log.debug("Retrieved expires_in");
}
}

if (!StringUtils.isEmpty(connectionTokens.getRefreshToken())) {
log.debug("Retrieved refresh_token");
}
if (0 <= connectionTokens.getExpiresIn()) {
log.debug("Retrieved expires_in");
private void logIfPresent(String token, String message) {
if (token != null && !token.isEmpty()) {
log.debug(message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.firebolt.jdbc.statement.rawstatement.RawStatement;
import com.firebolt.jdbc.util.CloseableUtil;
import com.firebolt.jdbc.util.PropertyUtil;
import com.google.common.collect.ImmutableMap;
import lombok.CustomLog;
import lombok.NonNull;
import okhttp3.Call;
Expand Down Expand Up @@ -232,7 +231,7 @@ private Optional<Pair<String, String>> getResponseFormatParameter(boolean isQuer
}

private Map<String, String> getCancelParameters(String statementId) {
return ImmutableMap.of(FireboltQueryParameterKey.QUERY_ID.getKey(), statementId);
return Map.of(FireboltQueryParameterKey.QUERY_ID.getKey(), statementId);
}

}
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
package com.firebolt.jdbc.service;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;

import com.firebolt.jdbc.client.authentication.FireboltAuthenticationClient;
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.ExpirationPolicy;
import net.jodah.expiringmap.ExpiringMap;
import org.apache.commons.lang3.StringUtils;

import javax.xml.bind.DatatypeConverter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Optional;
import java.util.concurrent.TimeUnit;

@RequiredArgsConstructor
@CustomLog
Expand Down Expand Up @@ -101,7 +99,7 @@ public ConnectParams(String fireboltHost, String user, String password) throws N
MessageDigest sha256Instance = MessageDigest.getInstance("SHA-256");
Optional.ofNullable(user).map(String::getBytes).ifPresent(sha256Instance::update);
Optional.ofNullable(password).map(String::getBytes).ifPresent(sha256Instance::update);
this.credentialsHash = new String(Hex.encodeHex(sha256Instance.digest()));
this.credentialsHash = DatatypeConverter.printHexBinary(sha256Instance.digest());
}
}
}
35 changes: 18 additions & 17 deletions src/main/java/com/firebolt/jdbc/type/BaseType.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
package com.firebolt.jdbc.type;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.*;
import java.util.TimeZone;

import javax.xml.bind.DatatypeConverter;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;

import com.firebolt.jdbc.CheckedFunction;
import com.firebolt.jdbc.exception.FireboltException;
import com.firebolt.jdbc.resultset.column.Column;
import com.firebolt.jdbc.type.array.SqlArrayUtil;
import com.firebolt.jdbc.type.date.SqlDateUtil;

import lombok.Builder;
import lombok.CustomLog;
import lombok.Value;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;

import javax.xml.bind.DatatypeConverter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Array;
import java.sql.Date;
import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.TimeZone;

/** This class contains the java types the Firebolt datatypes are mapped to */
@CustomLog
Expand Down Expand Up @@ -73,14 +74,14 @@ public enum BaseType {
conversion -> SqlArrayUtil.transformToSqlArray(conversion.getValue(), conversion.getColumn().getType())),
BYTEA(byte[].class, conversion -> {
String s = conversion.getValue();
if (StringUtils.startsWith(s, "\\x")) {
return DatatypeConverter.parseHexBinary(s.substring(2));
} else if (StringUtils.isEmpty(s)) {
if (s == null || s.isEmpty()) {
return new byte[] {};
} else {
// Cannot convert from other formats (such as 'Escape') for the moment
throw new FireboltException("Cannot convert binary string in non-hex format to byte array");
}
if (s.startsWith("\\x")) {
return DatatypeConverter.parseHexBinary(s.substring(2));
}
// Cannot convert from other formats (such as 'Escape') for the moment
throw new FireboltException("Cannot convert binary string in non-hex format to byte array");
});

public static final String NULL_VALUE = "\\N";
Expand Down
22 changes: 8 additions & 14 deletions src/main/java/com/firebolt/jdbc/type/array/SqlArrayUtil.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package com.firebolt.jdbc.type.array;

import java.lang.reflect.Array;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.lang3.StringUtils;

import com.firebolt.jdbc.exception.FireboltException;
import com.firebolt.jdbc.resultset.column.ColumnType;
import com.firebolt.jdbc.type.FireboltDataType;
import com.firebolt.jdbc.type.JavaTypeToFireboltSQLString;
import com.google.common.base.CharMatcher;

import lombok.CustomLog;
import lombok.NonNull;
import lombok.experimental.UtilityClass;
import org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Array;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@UtilityClass
@CustomLog
Expand Down Expand Up @@ -102,10 +99,7 @@ private static String getArraySeparator(int dimension) {
}

private static String removeQuotesAndTransformNull(String s) {
if (StringUtils.equals(s, "NULL")) {
return "\\N";
}
return CharMatcher.is('\'').trimFrom(s);
return "NULL".equals(s) ? "\\N" : StringUtils.strip(s, "'");
}

private static String removeParenthesis(String s) {
Expand Down
Loading

0 comments on commit 0e17fe3

Please sign in to comment.