Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Commit 3f357c2

Browse files
committed
fix: retry for specific exceptions
1 parent 1d1a5c5 commit 3f357c2

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

google-cloud-bigquery-jdbc/src/main/java/com/google/cloud/bigquery/jdbc/BigQueryStatement.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,9 @@ Thread populateArrowBufferedQueue(
841841
startTime = System.currentTimeMillis();
842842
}
843843
break;
844-
} catch (RuntimeException e) {
845-
if (e instanceof com.google.api.gax.rpc.ApiException
846-
&& ((com.google.api.gax.rpc.ApiException) e).getStatusCode().getCode()
847-
== com.google.api.gax.rpc.StatusCode.Code.NOT_FOUND) {
844+
} catch (com.google.api.gax.rpc.ApiException e) {
845+
if (e.getStatusCode().getCode()
846+
== com.google.api.gax.rpc.StatusCode.Code.NOT_FOUND) {
848847
LOG.warning("Read session expired or not found" + ": %s", e.getMessage());
849848
break;
850849
}
@@ -1075,15 +1074,12 @@ Thread runNextPageTaskAsync(
10751074
"Fetched %d results from the server in %d ms.",
10761075
querySettings.getMaxResultPerPage(),
10771076
(int) ((System.nanoTime() - startTime) / 1000000));
1078-
} catch (Exception ex) {
1079-
if (ex instanceof com.google.cloud.BaseServiceException
1080-
&& ((com.google.cloud.BaseServiceException) ex).getCode() == 404) {
1077+
} catch (com.google.cloud.bigquery.BigQueryException ex) {
1078+
if (ex.getCode() == 404) {
10811079
throw ex;
10821080
}
10831081
long elapsedSecs = (System.currentTimeMillis() - startTimeLoop) / 1000;
1084-
if (elapsedSecs >= retryTimeoutInSecs
1085-
|| ex instanceof InterruptedException
1086-
|| ex.getCause() instanceof InterruptedException) {
1082+
if (elapsedSecs >= retryTimeoutInSecs) {
10871083
throw ex;
10881084
}
10891085
retryCount++;
@@ -1096,6 +1092,9 @@ Thread runNextPageTaskAsync(
10961092
Thread.currentThread().interrupt();
10971093
throw new BigQueryJdbcRuntimeException(ie);
10981094
}
1095+
} catch (InterruptedException ie) {
1096+
Thread.currentThread().interrupt();
1097+
throw new BigQueryJdbcRuntimeException(ie);
10991098
}
11001099
}
11011100
// this will stop the parseDataTask as well when the pagination

0 commit comments

Comments
 (0)