Skip to content

Commit 7f7a7d7

Browse files
committed
fix(bigquery): translate HttpResponseException to BigQueryException in runWithRetries to enable retries on HTTP errors
1 parent fb49fb8 commit 7f7a7d7

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/BigQueryRetryHelper.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.google.cloud.bigquery;
1717

18+
import com.google.api.client.http.HttpResponseException;
1819
import com.google.api.core.ApiClock;
1920
import com.google.api.gax.retrying.DirectRetryingExecutor;
2021
import com.google.api.gax.retrying.ExponentialRetryAlgorithm;
@@ -69,8 +70,16 @@ public static <V> V runWithRetries(
6970
// implementation does not use response at all, so ignoring its type is ok.
7071
@SuppressWarnings("unchecked")
7172
ResultRetryAlgorithm<V> algorithm = (ResultRetryAlgorithm<V>) resultRetryAlgorithm;
73+
Callable<V> translatingCallable =
74+
() -> {
75+
try {
76+
return callable.call();
77+
} catch (HttpResponseException e) {
78+
throw new BigQueryException(e);
79+
}
80+
};
7281
return run(
73-
callable,
82+
translatingCallable,
7483
new ExponentialRetryAlgorithm(retrySettings, clock),
7584
algorithm,
7685
bigQueryRetryConfig);

0 commit comments

Comments
 (0)