@@ -73,6 +73,10 @@ public class Job extends JobInfo {
7373
7474 private final BigQueryOptions options ;
7575 private transient BigQuery bigquery ;
76+ private static final BigQueryRetryConfig DEFAULT_RETRY_CONFIG =
77+ BigQueryRetryConfig .newBuilder ()
78+ .retryOnMessage (BigQueryErrorMessages .RATE_LIMIT_EXCEEDED_MSG )
79+ .build (); // retry config with Error Message for RateLimitExceeded Error
7680
7781 /** A builder for {@code Job} objects. */
7882 public static final class Builder extends JobInfo .Builder {
@@ -319,30 +323,34 @@ public TableResult getQueryResults(QueryResultsOption... options)
319323 }
320324
321325 private QueryResponse waitForQueryResults (
322- RetrySettings waitSettings , final QueryResultsOption ... resultsOptions )
326+ RetrySettings retrySettings , final QueryResultsOption ... resultsOptions )
323327 throws InterruptedException {
324328 if (getConfiguration ().getType () != Type .QUERY ) {
325329 throw new UnsupportedOperationException (
326330 "Waiting for query results is supported only for " + Type .QUERY + " jobs" );
327331 }
328332
329333 try {
330- return RetryHelper . poll (
334+ return BigQueryRetryHelper . runWithRetries (
331335 new Callable <QueryResponse >() {
332336 @ Override
333337 public QueryResponse call () {
334338 return bigquery .getQueryResults (getJobId (), resultsOptions );
335339 }
336340 },
337- waitSettings ,
341+ retrySettings ,
338342 new BasicResultRetryAlgorithm <QueryResponse >() {
339343 @ Override
340- public boolean shouldRetry (Throwable prevThrowable , QueryResponse prevResponse ) {
344+ public boolean shouldRetry (
345+ Throwable prevThrowable ,
346+ QueryResponse
347+ prevResponse ) { // Used by BigQueryRetryAlgorithm.shouldRetryBasedOnResult
341348 return prevResponse != null && !prevResponse .getCompleted ();
342349 }
343350 },
344- options .getClock ());
345- } catch (ExecutionException e ) {
351+ options .getClock (),
352+ DEFAULT_RETRY_CONFIG );
353+ } catch (BigQueryRetryHelper .BigQueryRetryHelperException e ) {
346354 throw BigQueryException .translateAndThrow (e );
347355 }
348356 }
0 commit comments