diff --git a/.github/workflows/unmanaged_dependency_check.yaml b/.github/workflows/unmanaged_dependency_check.yaml
index 47fc0ec712..161d8328df 100644
--- a/.github/workflows/unmanaged_dependency_check.yaml
+++ b/.github/workflows/unmanaged_dependency_check.yaml
@@ -17,7 +17,7 @@ jobs:
# repository
.kokoro/build.sh
- name: Unmanaged dependency check
- uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.52.0
+ uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.52.1
with:
# java-bigquery does not produce a BOM. Fortunately the root pom.xml
# defines google-cloud-bigquery in dependencyManagement section. So
diff --git a/.kokoro/continuous/graalvm-native-a.cfg b/.kokoro/continuous/graalvm-native-a.cfg
index c6dbbdc522..849d5dcf13 100644
--- a/.kokoro/continuous/graalvm-native-a.cfg
+++ b/.kokoro/continuous/graalvm-native-a.cfg
@@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
- value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.52.0"
+ value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.52.1"
}
env_vars: {
diff --git a/.kokoro/continuous/graalvm-native-b.cfg b/.kokoro/continuous/graalvm-native-b.cfg
index 6c66c8d835..c6bb73143f 100644
--- a/.kokoro/continuous/graalvm-native-b.cfg
+++ b/.kokoro/continuous/graalvm-native-b.cfg
@@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
- value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.52.0"
+ value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.52.1"
}
env_vars: {
diff --git a/.kokoro/continuous/graalvm-native-c.cfg b/.kokoro/continuous/graalvm-native-c.cfg
index 2a4f45eaef..62182e63f1 100644
--- a/.kokoro/continuous/graalvm-native-c.cfg
+++ b/.kokoro/continuous/graalvm-native-c.cfg
@@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
- value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.52.0"
+ value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.52.1"
}
env_vars: {
diff --git a/.kokoro/presubmit/graalvm-native-a.cfg b/.kokoro/presubmit/graalvm-native-a.cfg
index c6dbbdc522..849d5dcf13 100644
--- a/.kokoro/presubmit/graalvm-native-a.cfg
+++ b/.kokoro/presubmit/graalvm-native-a.cfg
@@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
- value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.52.0"
+ value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.52.1"
}
env_vars: {
diff --git a/.kokoro/presubmit/graalvm-native-b.cfg b/.kokoro/presubmit/graalvm-native-b.cfg
index 6c66c8d835..c6bb73143f 100644
--- a/.kokoro/presubmit/graalvm-native-b.cfg
+++ b/.kokoro/presubmit/graalvm-native-b.cfg
@@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
- value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.52.0"
+ value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.52.1"
}
env_vars: {
diff --git a/.kokoro/presubmit/graalvm-native-c.cfg b/.kokoro/presubmit/graalvm-native-c.cfg
index 2a4f45eaef..62182e63f1 100644
--- a/.kokoro/presubmit/graalvm-native-c.cfg
+++ b/.kokoro/presubmit/graalvm-native-c.cfg
@@ -3,7 +3,7 @@
# Configure the docker image for kokoro-trampoline.
env_vars: {
key: "TRAMPOLINE_IMAGE"
- value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.52.0"
+ value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_c:3.52.1"
}
env_vars: {
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27dae85f7c..be6007f631 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,18 @@
# Changelog
+## [2.55.0](https://github.com/googleapis/java-bigquery/compare/v2.54.2...v2.55.0) (2025-09-12)
+
+
+### Features
+
+* **bigquery:** Add custom ExceptionHandler to BigQueryOptions ([#3937](https://github.com/googleapis/java-bigquery/issues/3937)) ([de0914d](https://github.com/googleapis/java-bigquery/commit/de0914ddbccf988294d50faf56a515e58ab3505d))
+
+
+### Dependencies
+
+* Update dependency com.google.cloud:google-cloud-bigquerystorage-bom to v3.17.0 ([#3954](https://github.com/googleapis/java-bigquery/issues/3954)) ([e73deed](https://github.com/googleapis/java-bigquery/commit/e73deed9c68a45023d02b40144c304329d6b5829))
+* Update dependency com.google.cloud:sdk-platform-java-config to v3.52.1 ([#3952](https://github.com/googleapis/java-bigquery/issues/3952)) ([79b7557](https://github.com/googleapis/java-bigquery/commit/79b7557501d318fd92b90a681036fe6a1aa1bac4))
+
## [2.54.2](https://github.com/googleapis/java-bigquery/compare/v2.54.1...v2.54.2) (2025-08-26)
diff --git a/benchmark/pom.xml b/benchmark/pom.xml
index ac28abddf6..688debd416 100644
--- a/benchmark/pom.xml
+++ b/benchmark/pom.xml
@@ -6,7 +6,7 @@
google-cloud-bigquery-parent
com.google.cloud
- 2.54.2
+ 2.55.0
diff --git a/google-cloud-bigquery-bom/pom.xml b/google-cloud-bigquery-bom/pom.xml
index cabb84cb3f..be30269f71 100644
--- a/google-cloud-bigquery-bom/pom.xml
+++ b/google-cloud-bigquery-bom/pom.xml
@@ -3,12 +3,12 @@
4.0.0
com.google.cloud
google-cloud-bigquery-bom
- 2.54.2
+ 2.55.0
pom
com.google.cloud
sdk-platform-java-config
- 3.52.0
+ 3.52.1
@@ -54,7 +54,7 @@
com.google.cloud
google-cloud-bigquery
- 2.54.2
+ 2.55.0
diff --git a/google-cloud-bigquery/pom.xml b/google-cloud-bigquery/pom.xml
index db8db1ad71..2cae0f6f11 100644
--- a/google-cloud-bigquery/pom.xml
+++ b/google-cloud-bigquery/pom.xml
@@ -3,7 +3,7 @@
4.0.0
com.google.cloud
google-cloud-bigquery
- 2.54.2
+ 2.55.0
jar
BigQuery
https://github.com/googleapis/java-bigquery
@@ -11,7 +11,7 @@
com.google.cloud
google-cloud-bigquery-parent
- 2.54.2
+ 2.55.0
google-cloud-bigquery
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryBaseService.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryBaseService.java
index 9760158735..bdcefb3d96 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryBaseService.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryBaseService.java
@@ -26,7 +26,7 @@ protected BigQueryBaseService(ServiceOptions options) {
super(options);
}
- public static final ExceptionHandler BIGQUERY_EXCEPTION_HANDLER =
+ public static final ExceptionHandler DEFAULT_BIGQUERY_EXCEPTION_HANDLER =
ExceptionHandler.newBuilder()
.abortOn(RuntimeException.class)
.retryOn(java.net.ConnectException.class) // retry on Connection Exception
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
index a32a600c3f..088d15c09c 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryImpl.java
@@ -293,7 +293,7 @@ public com.google.api.services.bigquery.model.Dataset call() throws IOException
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -340,7 +340,7 @@ public com.google.api.services.bigquery.model.Table call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -396,7 +396,7 @@ public com.google.api.services.bigquery.model.Routine call() throws IOException
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -490,7 +490,7 @@ public com.google.api.services.bigquery.model.Job call() throws IOException {
? RetryOption.mergeToSettings(
getOptions().getRetrySettings(), getRetryOptions(optionsMap))
: getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
getBigQueryRetryConfig(optionsMap) != null
? getBigQueryRetryConfig(optionsMap)
@@ -586,7 +586,7 @@ public com.google.api.services.bigquery.model.Dataset call() throws IOException
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -652,7 +652,7 @@ private static Page listDatasets(
}
},
serviceOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ serviceOptions.getResultRetryAlgorithm(),
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
@@ -704,7 +704,7 @@ public Boolean call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -755,7 +755,7 @@ public Boolean call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -801,7 +801,7 @@ public Boolean call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -847,7 +847,7 @@ public Boolean call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -891,7 +891,7 @@ public Boolean call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -932,7 +932,7 @@ public com.google.api.services.bigquery.model.Dataset call() throws IOException
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -979,7 +979,7 @@ public com.google.api.services.bigquery.model.Table call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -1025,7 +1025,7 @@ public com.google.api.services.bigquery.model.Model call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -1071,7 +1071,7 @@ public com.google.api.services.bigquery.model.Routine call() throws IOException
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -1125,7 +1125,7 @@ public com.google.api.services.bigquery.model.Table call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -1184,7 +1184,7 @@ public com.google.api.services.bigquery.model.Model call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -1243,7 +1243,7 @@ public com.google.api.services.bigquery.model.Routine call() throws IOException
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -1461,7 +1461,7 @@ public Tuple> cal
}
},
serviceOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ serviceOptions.getResultRetryAlgorithm(),
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
@@ -1502,7 +1502,7 @@ public Tuple> cal
}
},
serviceOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ serviceOptions.getResultRetryAlgorithm(),
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
@@ -1543,7 +1543,7 @@ private static Page listRoutines(
}
},
serviceOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ serviceOptions.getResultRetryAlgorithm(),
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
@@ -1625,7 +1625,7 @@ public TableDataInsertAllResponse call() throws Exception {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -1719,7 +1719,7 @@ public TableDataList call() throws IOException {
}
},
serviceOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ serviceOptions.getResultRetryAlgorithm(),
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
@@ -1793,7 +1793,7 @@ public com.google.api.services.bigquery.model.Job call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -1850,7 +1850,7 @@ public Tuple> call(
}
},
serviceOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ serviceOptions.getResultRetryAlgorithm(),
serviceOptions.getClock(),
EMPTY_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
@@ -1905,7 +1905,7 @@ public Boolean call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -1992,7 +1992,7 @@ public com.google.api.services.bigquery.model.QueryResponse call()
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
DEFAULT_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -2169,7 +2169,7 @@ public GetQueryResultsResponse call() throws IOException {
}
},
serviceOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ serviceOptions.getResultRetryAlgorithm(),
serviceOptions.getClock(),
DEFAULT_RETRY_CONFIG,
serviceOptions.isOpenTelemetryTracingEnabled(),
@@ -2240,7 +2240,7 @@ public com.google.api.services.bigquery.model.Policy call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -2286,7 +2286,7 @@ public com.google.api.services.bigquery.model.Policy call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -2334,7 +2334,7 @@ public com.google.api.services.bigquery.model.TestIamPermissionsResponse call()
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java
index 36eeb20869..7adb58d3a2 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryOptions.java
@@ -17,6 +17,7 @@
package com.google.cloud.bigquery;
import com.google.api.core.BetaApi;
+import com.google.api.gax.retrying.ResultRetryAlgorithm;
import com.google.cloud.ServiceDefaults;
import com.google.cloud.ServiceOptions;
import com.google.cloud.ServiceRpc;
@@ -43,6 +44,7 @@ public class BigQueryOptions extends ServiceOptions {
private JobCreationMode defaultJobCreationMode = JobCreationMode.JOB_CREATION_MODE_UNSPECIFIED;
private boolean enableOpenTelemetryTracing;
private Tracer openTelemetryTracer;
+ private ResultRetryAlgorithm> resultRetryAlgorithm;
public static class DefaultBigQueryFactory implements BigQueryFactory {
@@ -70,6 +72,7 @@ public static class Builder extends ServiceOptions.Builder resultRetryAlgorithm;
private Builder() {}
@@ -118,6 +121,11 @@ public Builder setOpenTelemetryTracer(Tracer tracer) {
return this;
}
+ public Builder setResultRetryAlgorithm(ResultRetryAlgorithm> resultRetryAlgorithm) {
+ this.resultRetryAlgorithm = resultRetryAlgorithm;
+ return this;
+ }
+
@Override
public BigQueryOptions build() {
return new BigQueryOptions(this);
@@ -130,6 +138,11 @@ private BigQueryOptions(Builder builder) {
this.useInt64Timestamps = builder.useInt64Timestamps;
this.enableOpenTelemetryTracing = builder.enableOpenTelemetryTracing;
this.openTelemetryTracer = builder.openTelemetryTracer;
+ if (builder.resultRetryAlgorithm != null) {
+ this.resultRetryAlgorithm = builder.resultRetryAlgorithm;
+ } else {
+ this.resultRetryAlgorithm = BigQueryBaseService.DEFAULT_BIGQUERY_EXCEPTION_HANDLER;
+ }
}
private static class BigQueryDefaults implements ServiceDefaults {
@@ -221,6 +234,10 @@ public Tracer getOpenTelemetryTracer() {
return openTelemetryTracer;
}
+ public ResultRetryAlgorithm> getResultRetryAlgorithm() {
+ return resultRetryAlgorithm;
+ }
+
@SuppressWarnings("unchecked")
@Override
public Builder toBuilder() {
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java
index b12ad85564..c3465c33a8 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/ConnectionImpl.java
@@ -474,7 +474,7 @@ private BigQueryResult queryRpc(
.getBigQueryRpcV2()
.queryRpcSkipExceptionTranslation(projectId, queryRequest),
bigQueryOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ bigQueryOptions.getResultRetryAlgorithm(),
bigQueryOptions.getClock(),
retryConfig,
false,
@@ -932,7 +932,7 @@ private Job getQueryJobRpc(JobId jobId) {
completeJobId.getJob(),
completeJobId.getLocation()),
bigQueryOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ bigQueryOptions.getResultRetryAlgorithm(),
bigQueryOptions.getClock(),
EMPTY_RETRY_CONFIG,
false,
@@ -979,7 +979,7 @@ TableDataList tableDataListRpc(TableId destinationTable, String pageToken) {
connectionSettings.getMaxResultPerPage(),
pageToken),
bigQueryOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ bigQueryOptions.getResultRetryAlgorithm(),
bigQueryOptions.getClock(),
EMPTY_RETRY_CONFIG,
false,
@@ -1212,7 +1212,7 @@ GetQueryResultsResponse getQueryResultsFirstPage(JobId jobId) {
connectionSettings.getMaxResultPerPage(),
timeoutMs),
bigQueryOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ bigQueryOptions.getResultRetryAlgorithm(),
bigQueryOptions.getClock(),
retryConfig,
false,
@@ -1477,7 +1477,7 @@ com.google.api.services.bigquery.model.Job createQueryJob(
.getBigQueryRpcV2()
.createJobForQuerySkipExceptionTranslation(jobPb),
bigQueryOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ bigQueryOptions.getResultRetryAlgorithm(),
bigQueryOptions.getClock(),
retryConfig,
false,
@@ -1522,7 +1522,7 @@ com.google.api.services.bigquery.model.Job createDryRunJob(String sql) {
.getBigQueryRpcV2()
.createJobForQuerySkipExceptionTranslation(jobPb),
bigQueryOptions.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ bigQueryOptions.getResultRetryAlgorithm(),
bigQueryOptions.getClock(),
retryConfig,
false,
diff --git a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableDataWriteChannel.java b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableDataWriteChannel.java
index cc64ec72f5..dde4c08187 100644
--- a/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableDataWriteChannel.java
+++ b/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableDataWriteChannel.java
@@ -77,7 +77,7 @@ public com.google.api.services.bigquery.model.Job call() throws IOException {
}
},
getOptions().getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ getOptions().getResultRetryAlgorithm(),
getOptions().getClock(),
EMPTY_RETRY_CONFIG,
getOptions().isOpenTelemetryTracingEnabled(),
@@ -126,7 +126,7 @@ public String call() throws IOException {
}
},
options.getRetrySettings(),
- BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER,
+ options.getResultRetryAlgorithm(),
options.getClock(),
EMPTY_RETRY_CONFIG,
options.isOpenTelemetryTracingEnabled(),
diff --git a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryExceptionTest.java b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryExceptionTest.java
index 41915e2834..8a2094b558 100644
--- a/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryExceptionTest.java
+++ b/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/BigQueryExceptionTest.java
@@ -21,7 +21,10 @@
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -29,9 +32,14 @@
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpResponseException;
import com.google.cloud.BaseServiceException;
+import com.google.cloud.ExceptionHandler;
import com.google.cloud.RetryHelper.RetryHelperException;
+import com.google.cloud.bigquery.spi.v2.BigQueryRpc;
+import com.google.cloud.bigquery.spi.v2.HttpBigQueryRpc;
import java.io.IOException;
import java.net.SocketTimeoutException;
+import java.util.HashMap;
+import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
@@ -158,4 +166,87 @@ public void testTranslateAndThrow() throws Exception {
verify(exceptionMock, times(2)).getCause();
}
}
+
+ @Test
+ public void testDefaultExceptionHandler() throws java.io.IOException {
+ BigQueryOptions defaultOptions =
+ BigQueryOptions.newBuilder().setProjectId("project-id").build();
+ DatasetInfo info = DatasetInfo.newBuilder("dataset").build();
+ Dataset dataset = null;
+
+ final com.google.api.services.bigquery.model.Dataset datasetPb =
+ info.setProjectId(defaultOptions.getProjectId()).toPb();
+ final Map optionsMap = new HashMap<>();
+
+ BigQueryOptions mockOptions = spy(defaultOptions);
+ HttpBigQueryRpc bigQueryRpcMock = mock(HttpBigQueryRpc.class);
+ doReturn(bigQueryRpcMock).when(mockOptions).getBigQueryRpcV2();
+ // java.net.SocketException is retry-able in the default exception handler.
+ doThrow(java.net.SocketException.class)
+ .when(bigQueryRpcMock)
+ .createSkipExceptionTranslation(datasetPb, optionsMap);
+
+ BigQuery bigquery = mockOptions.getService();
+ try {
+ dataset = bigquery.create(info);
+ } catch (BigQueryException e) {
+ assertEquals(e.getCause().getClass(), java.net.SocketException.class);
+ assertNull(dataset);
+ } finally {
+ verify(bigQueryRpcMock, times(6)).createSkipExceptionTranslation(datasetPb, optionsMap);
+ }
+ }
+
+ @Test
+ public void testCustomExceptionHandler() throws java.io.IOException {
+ BigQueryOptions defaultOptions =
+ BigQueryOptions.newBuilder()
+ .setProjectId("project-id")
+ .setResultRetryAlgorithm(
+ ExceptionHandler.newBuilder()
+ .abortOn(RuntimeException.class)
+ .retryOn(java.util.EmptyStackException.class)
+ .addInterceptors(BigQueryBaseService.EXCEPTION_HANDLER_INTERCEPTOR)
+ .build())
+ .build();
+ DatasetInfo info = DatasetInfo.newBuilder("dataset").build();
+ Dataset dataset = null;
+
+ final com.google.api.services.bigquery.model.Dataset datasetPb =
+ info.setProjectId(defaultOptions.getProjectId()).toPb();
+ final Map optionsMap = new HashMap<>();
+
+ BigQueryOptions mockOptions = spy(defaultOptions);
+ HttpBigQueryRpc bigQueryRpcRetryMock = mock(HttpBigQueryRpc.class);
+ doReturn(bigQueryRpcRetryMock).when(mockOptions).getBigQueryRpcV2();
+ doThrow(java.util.EmptyStackException.class)
+ .when(bigQueryRpcRetryMock)
+ .createSkipExceptionTranslation(datasetPb, optionsMap);
+
+ BigQuery bigquery = mockOptions.getService();
+ try {
+ dataset = bigquery.create(info);
+ } catch (BigQueryException e) {
+ assertEquals(e.getCause().getClass(), java.util.EmptyStackException.class);
+ assertNull(dataset);
+ } finally {
+ verify(bigQueryRpcRetryMock, times(6)).createSkipExceptionTranslation(datasetPb, optionsMap);
+ }
+
+ BigQueryOptions mockOptionsAbort = spy(defaultOptions);
+ HttpBigQueryRpc bigQueryRpcAbortMock = mock(HttpBigQueryRpc.class);
+ doReturn(bigQueryRpcAbortMock).when(mockOptionsAbort).getBigQueryRpcV2();
+ doThrow(RuntimeException.class)
+ .when(bigQueryRpcAbortMock)
+ .createSkipExceptionTranslation(datasetPb, optionsMap);
+ bigquery = mockOptionsAbort.getService();
+ try {
+ dataset = bigquery.create(info);
+ } catch (BigQueryException e) {
+ assertEquals(e.getCause().getClass(), RuntimeException.class);
+ assertNull(dataset);
+ } finally {
+ verify(bigQueryRpcAbortMock, times(1)).createSkipExceptionTranslation(datasetPb, optionsMap);
+ }
+ }
}
diff --git a/pom.xml b/pom.xml
index 06fa45550b..291ac9fd93 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
com.google.cloud
google-cloud-bigquery-parent
pom
- 2.54.2
+ 2.55.0
BigQuery Parent
https://github.com/googleapis/java-bigquery
@@ -14,7 +14,7 @@
com.google.cloud
sdk-platform-java-config
- 3.52.0
+ 3.52.1
@@ -71,7 +71,7 @@
com.google.cloud
google-cloud-bigquerystorage-bom
- 3.16.3
+ 3.17.0
pom
import
@@ -93,7 +93,7 @@
com.google.cloud
google-cloud-bigquery
- 2.54.2
+ 2.55.0
diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml
index 2290d681e5..c0e58826be 100644
--- a/samples/snapshot/pom.xml
+++ b/samples/snapshot/pom.xml
@@ -56,7 +56,7 @@
com.google.cloud
google-cloud-bigquery
- 2.54.2
+ 2.55.0
diff --git a/versions.txt b/versions.txt
index e5014dcc5c..73eeb870a4 100644
--- a/versions.txt
+++ b/versions.txt
@@ -1,4 +1,4 @@
# Format:
# module:released-version:current-version
-google-cloud-bigquery:2.54.2:2.54.2
\ No newline at end of file
+google-cloud-bigquery:2.55.0:2.55.0
\ No newline at end of file