From fd06ad2728e52eac2e8570b0ba15830ad79470ad Mon Sep 17 00:00:00 2001 From: Martin Vanek Date: Thu, 21 Oct 2021 19:46:12 +0100 Subject: [PATCH] fix: allow retry on connection establishing exceptions (#1666) --- .../google/cloud/bigquery/BigQueryImpl.java | 56 +++++++++---------- .../cloud/bigquery/TableDataWriteChannel.java | 4 +- 2 files changed, 30 insertions(+), 30 deletions(-) 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 fd9160f40..7d0e4c555 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 @@ -270,7 +270,7 @@ public com.google.api.services.bigquery.model.Dataset call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -298,7 +298,7 @@ public com.google.api.services.bigquery.model.Table call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -326,7 +326,7 @@ public com.google.api.services.bigquery.model.Routine call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -375,7 +375,7 @@ public com.google.api.services.bigquery.model.Job call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -426,7 +426,7 @@ public com.google.api.services.bigquery.model.Dataset call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); if (getOptions().getThrowNotFound() && answer == null) { throw new BigQueryException(HTTP_NOT_FOUND, "Dataset not found"); @@ -501,7 +501,7 @@ public Boolean call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -532,7 +532,7 @@ public Boolean call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -558,7 +558,7 @@ public Boolean call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -584,7 +584,7 @@ public Boolean call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -608,7 +608,7 @@ public Boolean call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -631,7 +631,7 @@ public com.google.api.services.bigquery.model.Dataset call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -659,7 +659,7 @@ public com.google.api.services.bigquery.model.Table call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -687,7 +687,7 @@ public com.google.api.services.bigquery.model.Model call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -715,7 +715,7 @@ public com.google.api.services.bigquery.model.Routine call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -751,7 +751,7 @@ public com.google.api.services.bigquery.model.Table call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); if (getOptions().getThrowNotFound() && answer == null) { throw new BigQueryException(HTTP_NOT_FOUND, "Table not found"); @@ -789,7 +789,7 @@ public com.google.api.services.bigquery.model.Model call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); if (getOptions().getThrowNotFound() && answer == null) { throw new BigQueryException(HTTP_NOT_FOUND, "Model not found"); @@ -827,7 +827,7 @@ public com.google.api.services.bigquery.model.Routine call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); if (getOptions().getThrowNotFound() && answer == null) { throw new BigQueryException(HTTP_NOT_FOUND, "Routine not found"); @@ -916,7 +916,7 @@ private static Page listTables( } }, serviceOptions.getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, serviceOptions.getClock()); String cursor = result.x(); Iterable
tables = @@ -953,7 +953,7 @@ private static Page listModels( } }, serviceOptions.getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, serviceOptions.getClock()); String cursor = result.x(); Iterable models = @@ -990,7 +990,7 @@ private static Page listRoutines( } }, serviceOptions.getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, serviceOptions.getClock()); String cursor = result.x(); Iterable routines = @@ -1055,7 +1055,7 @@ public TableDataInsertAllResponse call() throws Exception { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -1119,7 +1119,7 @@ public TableDataList call() { } }, serviceOptions.getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, serviceOptions.getClock()); String cursor = result.getPageToken(); Map pageOptionMap = @@ -1179,7 +1179,7 @@ public com.google.api.services.bigquery.model.Job call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); if (getOptions().getThrowNotFound() && answer == null) { throw new BigQueryException(HTTP_NOT_FOUND, "Job not found"); @@ -1208,7 +1208,7 @@ public Tuple> call( } }, serviceOptions.getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, serviceOptions.getClock()); String cursor = result.x(); Iterable jobs = @@ -1247,7 +1247,7 @@ public Boolean call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -1440,7 +1440,7 @@ public com.google.api.services.bigquery.model.Policy call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -1466,7 +1466,7 @@ public com.google.api.services.bigquery.model.Policy call() { } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock())); } catch (RetryHelperException e) { throw BigQueryException.translateAndThrow(e); @@ -1493,7 +1493,7 @@ public com.google.api.services.bigquery.model.TestIamPermissionsResponse call() } }, getOptions().getRetrySettings(), - EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); return response.getPermissions() == null ? ImmutableList.of() 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 f96f7892c..0f9632aea 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 @@ -60,7 +60,7 @@ public com.google.api.services.bigquery.model.Job call() { } }, getOptions().getRetrySettings(), - BigQueryImpl.EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, getOptions().getClock()); job = jobPb != null ? Job.fromPb(getOptions().getService(), jobPb) : null; } catch (RetryHelper.RetryHelperException e) { @@ -91,7 +91,7 @@ public String call() { } }, options.getRetrySettings(), - BigQueryImpl.EXCEPTION_HANDLER, + BigQueryBaseService.BIGQUERY_EXCEPTION_HANDLER, options.getClock()); } catch (RetryHelper.RetryHelperException e) { throw BigQueryException.translateAndThrow(e);