Skip to content

Commit

Permalink
fix: categorize a WatchdogTimeoutException as retriable for grpc Read…
Browse files Browse the repository at this point in the history
…Object (#2954)

By categorizing as retriable the client will be allowed to retry the request rather than failing out.
  • Loading branch information
BenWhitehead authored Feb 25, 2025
1 parent 297802d commit b53bd53
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.api.gax.rpc.ServerStreamingCallable;
import com.google.api.gax.rpc.StateCheckingResponseObserver;
import com.google.api.gax.rpc.StreamController;
import com.google.api.gax.rpc.WatchdogTimeoutException;
import com.google.cloud.BaseServiceException;
import com.google.cloud.storage.Conversions.Decoder;
import com.google.cloud.storage.Crc32cValue.Crc32cLengthKnown;
Expand Down Expand Up @@ -93,7 +94,12 @@ final class GapicUnbufferedReadableByteChannel
@Override
public boolean shouldRetry(
Throwable previousThrowable, java.lang.Object previousResponse) {
boolean shouldRetry = alg.shouldRetry(previousThrowable, null);
// unfortunately we can't unit test this as this time, because WatchdogTimeoutException
// does not have a publicly accessible way of constructing it.
boolean isWatchdogTimeout =
previousThrowable instanceof StorageException
&& previousThrowable.getCause() instanceof WatchdogTimeoutException;
boolean shouldRetry = isWatchdogTimeout || alg.shouldRetry(previousThrowable, null);
if (previousThrowable != null && !shouldRetry) {
result.setException(previousThrowable);
}
Expand Down

0 comments on commit b53bd53

Please sign in to comment.