From 7ed14978b6c8465dd572f9ac8b51a99b35c0b700 Mon Sep 17 00:00:00 2001 From: Dhia Bouassida Date: Thu, 5 Sep 2024 17:14:44 +0200 Subject: [PATCH] add dependency and adapt code to decompress zstd responses --- FIPS/pom.xml | 4 ++++ FIPS/scripts/check_content.sh | 4 ++-- ci/scripts/check_content.sh | 6 +++--- linkage-checker-exclusion-rules.xml | 5 ----- parent-pom.xml | 10 ++++++++++ pom.xml | 4 ++++ .../client/jdbc/DefaultResultStreamProvider.java | 3 +++ thin_public_pom.xml | 6 ++++++ 8 files changed, 32 insertions(+), 10 deletions(-) diff --git a/FIPS/pom.xml b/FIPS/pom.xml index 04fa6a5f5..dd994a297 100644 --- a/FIPS/pom.xml +++ b/FIPS/pom.xml @@ -429,6 +429,10 @@ org.jsoup ${shadeBase}.org.jsoup + + com.github.luben.zstd + ${shadeBase}.com.github.luben.zstd + com.nimbusds ${shadeBase}.com.nimbusds diff --git a/FIPS/scripts/check_content.sh b/FIPS/scripts/check_content.sh index 8b818b1b4..fa675655e 100755 --- a/FIPS/scripts/check_content.sh +++ b/FIPS/scripts/check_content.sh @@ -1,12 +1,12 @@ #!/bin/bash -e -# scripts used to check if all dependency is shaded into snowflake internal path +# scripts used to check if all dependencies are shaded into snowflake internal path set -o pipefail DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -if jar tvf $DIR/../target/snowflake-jdbc-fips.jar | awk '{print $8}' | grep -v -E "^(net|com)/snowflake" | grep -v -E "(com|net)/\$" | grep -v -E "^META-INF" | grep -v -E "^mozilla" | grep -v -E "^com/sun/jna" | grep -v com/sun/ | grep -v mime.types; then +if jar tvf $DIR/../target/snowflake-jdbc-fips.jar | awk '{print $8}' | grep -v -E "^(net|com)/snowflake" | grep -v -E "(com|net)/\$" | grep -v -E "^META-INF" | grep -v -E "^mozilla" | grep -v -E "^com/sun/jna" | grep -v com/sun/ | grep -v mime.types | grep -v -E "^aix/" | grep -v -E "^darwin/" | grep -v -E "^freebsd/" | grep -v -E "^linux/" | grep -v -E "^win/"; then echo "[ERROR] JDBC jar includes class not under the snowflake namespace" exit 1 fi diff --git a/ci/scripts/check_content.sh b/ci/scripts/check_content.sh index a9c0768b6..ce6f34180 100755 --- a/ci/scripts/check_content.sh +++ b/ci/scripts/check_content.sh @@ -8,12 +8,12 @@ set -o pipefail DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" -if jar tvf $DIR/../../target/snowflake-jdbc${package_modifier}.jar | awk '{print $8}' | grep -v -E "^(net|com)/snowflake" | grep -v -E "(com|net)/\$" | grep -v -E "^META-INF" | grep -v -E "^mozilla" | grep -v -E "^com/sun/jna" | grep -v com/sun/ | grep -v mime.types; then +if jar tvf $DIR/../../target/snowflake-jdbc${package_modifier}.jar | awk '{print $8}' | grep -v -E "^(net|com)/snowflake" | grep -v -E "(com|net)/\$" | grep -v -E "^META-INF" | grep -v -E "^mozilla" | grep -v -E "^com/sun/jna" | grep -v com/sun/ | grep -v mime.types | grep -v -E "^aix/" | grep -v -E "^darwin/" | grep -v -E "^freebsd/" | grep -v -E "^linux/" | grep -v -E "^win/"; then echo "[ERROR] JDBC jar includes class not under the snowflake namespace" exit 1 fi -if jar tvf $DIR/../../target/snowflake-jdbc${package_modifier}.jar | awk '{print $8}' | grep -E "^META-INF/versions/.*.class" | grep -v -E "^META-INF/versions/.*/(net|com)/snowflake"; then - echo "[ERROR] JDBC jar includes multi release classes not under the snowflake namespace" +if jar tvf $DIR/../../target/snowflake-jdbc${package_modifier}.jar | awk '{print $8}' | grep -E "^META-INF/versions/.*.class" | grep -v -E "^META-INF/versions/.*/(net|com)/snowflake" | grep -v -E "^aix/" | grep -v -E "^darwin/" | grep -v -E "^freebsd/" | grep -v -E "^linux/" | grep -v -E "^win/"; then + echo "[ERROR] JDBC jar includes multi-release classes not under the snowflake namespace" exit 1 fi diff --git a/linkage-checker-exclusion-rules.xml b/linkage-checker-exclusion-rules.xml index 8bad89714..0f6275008 100644 --- a/linkage-checker-exclusion-rules.xml +++ b/linkage-checker-exclusion-rules.xml @@ -19,11 +19,6 @@ Optional - - - - Optional - diff --git a/parent-pom.xml b/parent-pom.xml index 28412d161..04dc541e0 100644 --- a/parent-pom.xml +++ b/parent-pom.xml @@ -19,6 +19,7 @@ 1.10.0 4.5.14 4.4.16 + 1.5.6-5 17.0.0 9.3 1.8.1 @@ -327,6 +328,11 @@ httpcore ${apache.httpcore.version} + + com.github.luben + zstd-jni + ${zstd-jni.version} + org.apache.tika tika-core @@ -644,6 +650,10 @@ org.apache.httpcomponents httpcore + + com.github.luben + zstd-jni + org.apache.tika tika-core diff --git a/pom.xml b/pom.xml index 096641174..e41cb7f62 100644 --- a/pom.xml +++ b/pom.xml @@ -947,6 +947,10 @@ android.annotation ${shadeBase}.android.annotation + + com.github.luben.zstd + ${shadeBase}.com.github.luben.zstd + diff --git a/src/main/java/net/snowflake/client/jdbc/DefaultResultStreamProvider.java b/src/main/java/net/snowflake/client/jdbc/DefaultResultStreamProvider.java index 3ee556bb4..567db8fa1 100644 --- a/src/main/java/net/snowflake/client/jdbc/DefaultResultStreamProvider.java +++ b/src/main/java/net/snowflake/client/jdbc/DefaultResultStreamProvider.java @@ -2,6 +2,7 @@ import static net.snowflake.client.core.Constants.MB; +import com.github.luben.zstd.ZstdInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PushbackInputStream; @@ -153,6 +154,8 @@ private InputStream detectContentEncodingAndGetInputStream(HttpResponse response if ("gzip".equalsIgnoreCase(encoding.getValue())) { /* specify buffer size for GZIPInputStream */ inputStream = new GZIPInputStream(is, STREAM_BUFFER_SIZE); + } else if ("zstd".equalsIgnoreCase(encoding.getValue())) { + inputStream = new ZstdInputStream(is); } else { throw new SnowflakeSQLException( SqlState.INTERNAL_ERROR, diff --git a/thin_public_pom.xml b/thin_public_pom.xml index 31a1aedee..a781a376d 100644 --- a/thin_public_pom.xml +++ b/thin_public_pom.xml @@ -64,6 +64,7 @@ UTF-8 2.0.13 1.6.9 + 1.5.6-5 @@ -262,6 +263,11 @@ jsoup ${jsoup.version} + + com.github.luben + zstd-jni + ${zstd-jni.version} + org.slf4j slf4j-api