sdk-java icon indicating copy to clipboard operation
sdk-java copied to clipboard

Sync versions of GrpcRetryer should throw InterruptedException

Open Spikhalskiy opened this issue 4 years ago • 0 comments

GrpcRetryer retry method by its nature is expected to throw InterruptedException because they

  1. perform waiting on a timer
  2. could get an Interrupted flag from GRPC calls with a StatusRuntimeException exception with CANCELLED status

Now handling of InterruptedExceptions is brittle:

  1. we hide the Interrupted exceptions from the timer and we raise an Interrupted flag instead.
  2. We consider StatusRuntimeException with CANCELLED from GRPC as non-retryable.

So, code that uses GrpcRetryer should expect a non-Interrupted Exception + Interrupted flag if interruption happens. There is nothing wrong with the model per se if the users are very aware of the potential interrupted flag and process it correctly. But to make code more idiomatic and enforce the correct handling of InterruptedException and awareness of its possibility inside GrpcRetryer, we should change GrpcRetryer methods to throw explicit InterruptedExceptions.

Spikhalskiy avatar Aug 23 '21 15:08 Spikhalskiy