sdk-java
sdk-java copied to clipboard
Sync versions of GrpcRetryer should throw InterruptedException
GrpcRetryer retry method by its nature is expected to throw InterruptedException because they
- perform waiting on a timer
- could get an Interrupted flag from GRPC calls with a StatusRuntimeException exception with CANCELLED status
Now handling of InterruptedExceptions is brittle:
- we hide the Interrupted exceptions from the timer and we raise an Interrupted flag instead.
- 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.