Skip to content

Commit

Permalink
Prevent action-cache duplicate suppression
Browse files Browse the repository at this point in the history
Exceptions that are reused between download futures must not be added to
the suppression of themselves.

Fixes #9362

Closes #9376.

PiperOrigin-RevId: 270658205
  • Loading branch information
George Gensure authored and dslomov committed Oct 14, 2019
1 parent 9c257df commit 9cb225a
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -354,13 +354,13 @@ public void download(
} catch (IOException e) {
if (downloadException == null) {
downloadException = e;
} else {
} else if (e != downloadException) {
downloadException.addSuppressed(e);
}
} catch (InterruptedException e) {
if (interruptedException == null) {
interruptedException = e;
} else {
} else if (e != interruptedException) {
interruptedException.addSuppressed(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,64 @@ public void downloadWithMultipleErrorsAddsThemAsSuppressed() throws Exception {
assertThat(Throwables.getRootCause(e)).hasMessageThat().isEqualTo("file2 failed");
}

@Test
public void downloadWithDuplicateIOErrorsDoesNotSuppress() throws Exception {
Path stdout = fs.getPath("/execroot/stdout");
Path stderr = fs.getPath("/execroot/stderr");

DefaultRemoteActionCache cache = newTestCache();
Digest digest1 = cache.addContents("file1");
IOException reusedException = new IOException("reused io exception");
Digest digest2 = cache.addException("file2", reusedException);
Digest digest3 = cache.addException("file3", reusedException);

ActionResult result =
ActionResult.newBuilder()
.setExitCode(0)
.addOutputFiles(OutputFile.newBuilder().setPath("file1").setDigest(digest1))
.addOutputFiles(OutputFile.newBuilder().setPath("file2").setDigest(digest2))
.addOutputFiles(OutputFile.newBuilder().setPath("file3").setDigest(digest3))
.build();
IOException e =
assertThrows(
IOException.class,
() ->
cache.download(
result, execRoot, new FileOutErr(stdout, stderr), outputFilesLocker));

assertThat(e.getSuppressed()).isEmpty();
assertThat(Throwables.getRootCause(e)).hasMessageThat().isEqualTo("reused io exception");
}

@Test
public void downloadWithDuplicateInterruptionsDoesNotSuppress() throws Exception {
Path stdout = fs.getPath("/execroot/stdout");
Path stderr = fs.getPath("/execroot/stderr");

DefaultRemoteActionCache cache = newTestCache();
Digest digest1 = cache.addContents("file1");
InterruptedException reusedInterruption = new InterruptedException("reused interruption");
Digest digest2 = cache.addException("file2", reusedInterruption);
Digest digest3 = cache.addException("file3", reusedInterruption);

ActionResult result =
ActionResult.newBuilder()
.setExitCode(0)
.addOutputFiles(OutputFile.newBuilder().setPath("file1").setDigest(digest1))
.addOutputFiles(OutputFile.newBuilder().setPath("file2").setDigest(digest2))
.addOutputFiles(OutputFile.newBuilder().setPath("file3").setDigest(digest3))
.build();
InterruptedException e =
assertThrows(
InterruptedException.class,
() ->
cache.download(
result, execRoot, new FileOutErr(stdout, stderr), outputFilesLocker));

assertThat(e.getSuppressed()).isEmpty();
assertThat(Throwables.getRootCause(e)).hasMessageThat().isEqualTo("reused interruption");
}

@Test
public void testDownloadWithStdoutStderrOnSuccess() throws Exception {
// Tests that fetching stdout/stderr as a digest works and that OutErr is still
Expand Down

0 comments on commit 9cb225a

Please sign in to comment.