Skip to content

Commit

Permalink
fix: Split retryable codes for streams, and retry RESOURCE_EXHAUSTED …
Browse files Browse the repository at this point in the history
…errors.
  • Loading branch information
manuelmenzella-google committed Sep 10, 2020
1 parent 36b472b commit e4efe0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ public final class ErrorCodes {
ImmutableSet.of(
Code.DEADLINE_EXCEEDED, Code.ABORTED, Code.INTERNAL, Code.UNAVAILABLE, Code.UNKNOWN);

public static final ImmutableSet<Code> STREAM_RETRYABLE_CODES =
ImmutableSet.<Code>builder().addAll(RETRYABLE_CODES).add(Code.RESOURCE_EXHAUSTED).build();

public static boolean IsRetryable(Code code) {
return RETRYABLE_CODES.contains(code);
}

public static boolean IsRetryableForStreams(Code code) {
return STREAM_RETRYABLE_CODES.contains(code);
}

private ErrorCodes() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public final void onError(Throwable t) {
setPermanentError(t);
return;
}
if (!ErrorCodes.IsRetryable(statusOr.get().getCode())) {
if (!ErrorCodes.IsRetryableForStreams(statusOr.get().getCode())) {
setPermanentError(statusOr.get().asRuntimeException());
return;
}
Expand Down

0 comments on commit e4efe0b

Please sign in to comment.