Skip to content

Commit

Permalink
Merge branch 'master' into SNOW-1732907-custom-azure-headers
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dheyman authored Oct 15, 2024
2 parents fbc5449 + f425350 commit e61605d
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 16 deletions.
6 changes: 3 additions & 3 deletions FIPS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -596,15 +596,15 @@
<unzip dest="${project.build.directory}/relocate" src="${project.build.directory}/${project.build.finalName}.jar"/>
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/21/${relocationBase}"/>
<!-- com.fasterxml.* packages are relocated to ${relocationBase}.fasterxml.* -->
<move file="${project.build.directory}/relocate/META-INF/versions/11/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/17/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/19/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/21/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/21/${relocationBase}"/>
<zip basedir="${project.build.directory}/relocate" destfile="${project.build.directory}/${project.build.finalName}.jar"/>
<delete dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<delete dir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
<delete dir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
<delete dir="${project.build.directory}/relocate/META-INF/versions/21/${relocationBase}"/>
</target>
</configuration>
</execution>
Expand Down
4 changes: 2 additions & 2 deletions FIPS/public_pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</scm>

<properties>
<bouncycastle.bcfips.version>1.0.2.4</bouncycastle.bcfips.version>
<bouncycastle.bcpkixfips.version>1.0.5</bouncycastle.bcpkixfips.version>
<bouncycastle.bcfips.version>1.0.2.5</bouncycastle.bcfips.version>
<bouncycastle.bcpkixfips.version>1.0.7</bouncycastle.bcpkixfips.version>
<jna.version>5.13.0</jna.version>
</properties>

Expand Down
10 changes: 10 additions & 0 deletions linkage-checker-exclusion-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
<Source><Package name="org.bouncycastle.pkix"/></Source>
<Reason>?</Reason>
</LinkageError>
<LinkageError>
<Target><Package name="java.nio"/></Target>
<Source><Package name="org.bouncycastle.jcajce.provider.symmetric.util"/></Source>
<Reason>?</Reason>
</LinkageError>
<LinkageError>
<Target><Package name="java.nio"/></Target>
<Source><Package name="org.bouncycastle.pqc.legacy.crypto.ntru"/></Source>
<Reason>?</Reason>
</LinkageError>
<!--
<LinkageError>
<Target><Package name=""/></Target>
Expand Down
12 changes: 9 additions & 3 deletions parent-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
<awaitility.version>4.2.0</awaitility.version>
<awssdk.version>1.12.655</awssdk.version>
<azure.storage.version>5.0.0</azure.storage.version>
<bouncycastle.version>1.74</bouncycastle.version>
<bouncycastle.bcfips.version>1.0.2.4</bouncycastle.bcfips.version>
<bouncycastle.bcpkixfips.version>1.0.5</bouncycastle.bcpkixfips.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<bouncycastle.bcfips.version>1.0.2.5</bouncycastle.bcfips.version>
<bouncycastle.bcpkixfips.version>1.0.7</bouncycastle.bcpkixfips.version>
<bytebuddy.version>1.14.17</bytebuddy.version>
<classworlds.version>1.1</classworlds.version>
<checkerframework.version>3.33.0</checkerframework.version>
Expand Down Expand Up @@ -448,6 +448,12 @@
<artifactId>bcprov-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<!-- for non-FIPS JAR -->
<groupId>org.bouncycastle</groupId>
<artifactId>bcutil-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<!-- for FIPS JAR -->
<groupId>org.bouncycastle</groupId>
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcutil-jdk18on</artifactId>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -1031,6 +1035,7 @@
<move file="${project.build.directory}/relocate/META-INF/versions/9/org" todir="${project.build.directory}/relocate/META-INF/versions/9/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/11/org" todir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/15/org" todir="${project.build.directory}/relocate/META-INF/versions/15/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/21/org" todir="${project.build.directory}/relocate/META-INF/versions/21/${relocationBase}"/>
<!-- com.fasterxml.* packages are relocated to ${relocationBase}.fasterxml.* -->
<move file="${project.build.directory}/relocate/META-INF/versions/11/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/17/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
Expand Down Expand Up @@ -1105,7 +1110,7 @@
<!--
Downloading
1. japicmp
2. maven-dependency-lugin analyst
2. maven-dependency-plugin analyst
in jenkins node would cause http connection failure. Temporarily disable them.
-->
<plugin>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/snowflake/client/core/CancellationReason.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 Snowflake Computing Inc. All rights reserved.
*/
package net.snowflake.client.core;

@SnowflakeJdbcInternalApi
public enum CancellationReason {
UNKNOWN,
CLIENT_REQUESTED,
TIMEOUT
}
14 changes: 14 additions & 0 deletions src/main/java/net/snowflake/client/core/SFBaseStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,23 @@ public abstract SFBaseResultSet asyncExecute(
*
* @throws SFException if the statement is already closed.
* @throws SQLException if there are server-side errors from trying to abort.
* @deprecated use {@link #cancel(CancellationReason)} instead
*/
@Deprecated
public abstract void cancel() throws SFException, SQLException;

/**
* Aborts the statement.
*
* @param cancellationReason reason for the cancellation
* @throws SFException if the statement is already closed.
* @throws SQLException if there are server-side errors from trying to abort.
*/
@SnowflakeJdbcInternalApi
public void cancel(CancellationReason cancellationReason) throws SFException, SQLException {
cancel(); // default cancel is called to keep interface backward compatibility
}

/**
* Sets a property within session properties, i.e., if the sql is using set-sf-property
*
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/net/snowflake/client/core/SFStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private TimeBombTask(SFStatement statement) {
@Override
public Void call() throws SQLException {
try {
statement.cancel();
statement.cancel(CancellationReason.TIMEOUT);
} catch (SFException ex) {
throw new SnowflakeSQLLoggedException(
session, ex.getSqlState(), ex.getVendorCode(), ex, ex.getParams());
Expand Down Expand Up @@ -711,10 +711,11 @@ private void reauthenticate() throws SFException, SnowflakeSQLException {
*
* @param sql sql statement
* @param mediaType media type
* @param cancellationReason reason for the cancellation
* @throws SnowflakeSQLException if failed to cancel the statement
* @throws SFException if statement is already closed
*/
private void cancelHelper(String sql, String mediaType)
private void cancelHelper(String sql, String mediaType, CancellationReason cancellationReason)
throws SnowflakeSQLException, SFException {
synchronized (this) {
if (isClosed) {
Expand All @@ -734,7 +735,7 @@ private void cancelHelper(String sql, String mediaType)
.setMaxRetries(session.getMaxHttpRetries())
.setHttpClientSettingsKey(session.getHttpClientKey());

StmtUtil.cancel(stmtInput);
StmtUtil.cancel(stmtInput, cancellationReason);

synchronized (this) {
/*
Expand Down Expand Up @@ -842,6 +843,12 @@ public void close() {
@Override
public void cancel() throws SFException, SQLException {
logger.trace("void cancel()", false);
cancel(CancellationReason.UNKNOWN);
}

@Override
public void cancel(CancellationReason cancellationReason) throws SFException, SQLException {
logger.trace("void cancel(CancellationReason)", false);

if (canceling.get()) {
logger.debug("Query is already cancelled", false);
Expand All @@ -866,7 +873,7 @@ public void cancel() throws SFException, SQLException {
}

// cancel the query on the server side if it has been issued
cancelHelper(this.sqlText, StmtUtil.SF_MEDIA_TYPE);
cancelHelper(this.sqlText, StmtUtil.SF_MEDIA_TYPE, cancellationReason);
}
}

Expand Down
17 changes: 16 additions & 1 deletion src/main/java/net/snowflake/client/core/StmtUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,23 @@ protected static JsonNode getQueryResultJSON(String queryId, SFSession session)
* @param stmtInput input statement
* @throws SFException if there is an internal exception
* @throws SnowflakeSQLException if failed to cancel the statement
* @deprecated use {@link #cancel(StmtInput, CancellationReason)} instead
*/
@Deprecated
public static void cancel(StmtInput stmtInput) throws SFException, SnowflakeSQLException {
cancel(stmtInput, CancellationReason.UNKNOWN);
}

/**
* Cancel a statement identifiable by a request id
*
* @param stmtInput input statement
* @param cancellationReason reason for the cancellation
* @throws SFException if there is an internal exception
* @throws SnowflakeSQLException if failed to cancel the statement
*/
public static void cancel(StmtInput stmtInput, CancellationReason cancellationReason)
throws SFException, SnowflakeSQLException {
HttpPost httpRequest = null;

AssertUtil.assertTrue(
Expand All @@ -701,7 +716,7 @@ public static void cancel(StmtInput stmtInput) throws SFException, SnowflakeSQLE

try {
URIBuilder uriBuilder = new URIBuilder(stmtInput.serverUrl);

logger.warn("Cancelling query {} with reason {}", stmtInput.requestId, cancellationReason);
logger.debug("Aborting query: {}", stmtInput.sql);

uriBuilder.setPath(SF_PATH_ABORT_REQUEST_V1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import net.snowflake.client.core.CancellationReason;
import net.snowflake.client.core.ExecTimeTelemetryData;
import net.snowflake.client.core.ParameterBindingDTO;
import net.snowflake.client.core.ResultUtil;
Expand Down Expand Up @@ -952,7 +953,7 @@ public void cancel() throws SQLException {
raiseSQLExceptionIfStatementIsClosed();

try {
sfBaseStatement.cancel();
sfBaseStatement.cancel(CancellationReason.CLIENT_REQUESTED);
} catch (SFException ex) {
throw new SnowflakeSQLException(ex, ex.getSqlState(), ex.getVendorCode(), ex.getParams());
}
Expand Down
7 changes: 6 additions & 1 deletion thin_public_pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<apache.httpcore.version>4.4.16</apache.httpcore.version>
<awssdk.version>1.12.655</awssdk.version>
<azure.storage.version>5.0.0</azure.storage.version>
<bouncycastle.version>1.74</bouncycastle.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<commons.codec.version>1.17.0</commons.codec.version>
<commons.io.version>2.11.0</commons.io.version>
<commons.logging.version>1.2</commons.logging.version>
Expand Down Expand Up @@ -117,6 +117,11 @@
<artifactId>bcprov-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcutil-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-core</artifactId>
Expand Down

0 comments on commit e61605d

Please sign in to comment.