Skip to content

Commit

Permalink
Wrap FindMissingBlobs exceptions in IOException
Browse files Browse the repository at this point in the history
Consistent with bazelbuild#7860, present an IOException with context to ensure
fallback if configured, rather than an unhandled RuntimeException and
bazel crash, when issuing FindMissingBlobs requests.
  • Loading branch information
George Gensure committed Jan 27, 2020
1 parent 84d9c71 commit 18914ac
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public ListenableFuture<ImmutableSet<Digest>> findMissingDigests(Iterable<Digest
getMissingDigestCalls.add(getMissingDigests(requestBuilder.build()));
}

return Futures.whenAllSucceed(getMissingDigestCalls)
ListenableFuture<ImmutableSet<Digest>> success = Futures.whenAllSucceed(getMissingDigestCalls)
.call(
() -> {
ImmutableSet.Builder<Digest> result = ImmutableSet.builder();
Expand All @@ -201,6 +201,17 @@ public ListenableFuture<ImmutableSet<Digest>> findMissingDigests(Iterable<Digest
return result.build();
},
MoreExecutors.directExecutor());
return Futures.catchingAsync(
success,
Exception.class,
(e) -> Futures.immediateFailedFuture(
new IOException(
String.format(
"findMissingBlobs(%d) for %s",
requestBuilder.getBlobDigestsCount(),
TracingMetadataUtils.fromCurrentContext().getActionId()),
e)),
MoreExecutors.directExecutor());
}

private ListenableFuture<FindMissingBlobsResponse> getMissingDigests(
Expand Down

0 comments on commit 18914ac

Please sign in to comment.