Fix a race condition in remote cache Previously, outerF.setExeception was set before closing the output stream of the download file when download fails. This was causing a permission error when trying to delete the file on Windows. Fixes https://github.com/bazelbuild/bazel/issues/6890 RELNOTES: None PiperOrigin-RevId: 228138102
diff --git a/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java b/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java index 55e295e..fe5d937 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java
@@ -426,12 +426,13 @@ @Override public void onFailure(Throwable t) { - outerF.setException(t); try { out.close(); } catch (IOException e) { // Intentionally left empty. The download already failed, so we can ignore // the error on close(). + } finally { + outerF.setException(t); } } },