Skip to content

Commit b53bd53

Browse files
authored
fix: categorize a WatchdogTimeoutException as retriable for grpc ReadObject (#2954)
By categorizing as retriable the client will be allowed to retry the request rather than failing out.
1 parent 297802d commit b53bd53

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

google-cloud-storage/src/main/java/com/google/cloud/storage/GapicUnbufferedReadableByteChannel.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.api.gax.rpc.ServerStreamingCallable;
2626
import com.google.api.gax.rpc.StateCheckingResponseObserver;
2727
import com.google.api.gax.rpc.StreamController;
28+
import com.google.api.gax.rpc.WatchdogTimeoutException;
2829
import com.google.cloud.BaseServiceException;
2930
import com.google.cloud.storage.Conversions.Decoder;
3031
import com.google.cloud.storage.Crc32cValue.Crc32cLengthKnown;
@@ -93,7 +94,12 @@ final class GapicUnbufferedReadableByteChannel
9394
@Override
9495
public boolean shouldRetry(
9596
Throwable previousThrowable, java.lang.Object previousResponse) {
96-
boolean shouldRetry = alg.shouldRetry(previousThrowable, null);
97+
// unfortunately we can't unit test this as this time, because WatchdogTimeoutException
98+
// does not have a publicly accessible way of constructing it.
99+
boolean isWatchdogTimeout =
100+
previousThrowable instanceof StorageException
101+
&& previousThrowable.getCause() instanceof WatchdogTimeoutException;
102+
boolean shouldRetry = isWatchdogTimeout || alg.shouldRetry(previousThrowable, null);
97103
if (previousThrowable != null && !shouldRetry) {
98104
result.setException(previousThrowable);
99105
}

0 commit comments

Comments
 (0)