diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionCache.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionCache.java index 421313edaea921..d614e52aac9881 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteExecutionCache.java @@ -229,11 +229,6 @@ public void onComplete() { @Override public void onError(@NonNull Throwable e) { - Disposable d = uploadTask.disposable.get(); - if (d != null && d.isDisposed()) { - return; - } - completion.onError(e); } }); diff --git a/src/test/java/com/google/devtools/build/lib/remote/RemoteCacheTest.java b/src/test/java/com/google/devtools/build/lib/remote/RemoteCacheTest.java index 196938ef5ab94a..bbea2e9c834236 100644 --- a/src/test/java/com/google/devtools/build/lib/remote/RemoteCacheTest.java +++ b/src/test/java/com/google/devtools/build/lib/remote/RemoteCacheTest.java @@ -79,6 +79,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import org.junit.After; +import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -565,6 +566,34 @@ public void ensureInputsPresent_interruptedDuringUploadBlobs_cancelInProgressUpl assertThat(remoteCache.casUploadCache.getFinishedTasks()).hasSize(3); } + @Test + public void ensureInputsPresent_uploadFailed_propagateErrors() throws Exception { + RemoteCacheClient cacheProtocol = spy(new InMemoryCacheClient()); + doAnswer( + invocationOnMock -> { + return Futures.immediateFailedFuture(new IOException("upload failed")); + }) + .when(cacheProtocol) + .uploadBlob(any(), any(), any()); + doAnswer( + invocationOnMock -> { + return Futures.immediateFailedFuture(new IOException("upload failed")); + }) + .when(cacheProtocol) + .uploadFile(any(), any(), any()); + RemoteExecutionCache remoteCache = spy(newRemoteExecutionCache(cacheProtocol)); + Path path = fs.getPath("/execroot/foo"); + FileSystemUtils.writeContentAsLatin1(path, "bar"); + SortedMap inputs = new TreeMap<>(); + inputs.put(PathFragment.create("foo"), path); + MerkleTree merkleTree = MerkleTree.build(inputs, digestUtil); + + IOException e = Assert.assertThrows(IOException.class, + () -> remoteCache.ensureInputsPresent(context, merkleTree, ImmutableMap.of(), false)); + + assertThat(e).hasMessageThat().contains("upload failed"); + } + @Test public void shutdownNow_cancelInProgressUploads() throws Exception { RemoteCacheClient remoteCacheClient = mock(RemoteCacheClient.class);