Skip to content

Commit a73aa12

Browse files
coeuvrecopybara-github
authored andcommitted
Remote: Fix crashes with InterruptedException when using http cache.
Also cancels tasks submitted during `afterCommand` if interrupted. Fixes bazelbuild#14787. Closes bazelbuild#14992. PiperOrigin-RevId: 433205726
1 parent 426188c commit a73aa12

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/main/java/com/google/devtools/build/lib/remote/http/HttpCacheClient.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,23 @@ public void close() {
729729
}
730730

731731
isClosed = true;
732-
channelPool.close();
732+
733+
// Clear interrupted status to prevent failure to close, indicated with #14787
734+
boolean wasInterrupted = Thread.interrupted();
735+
try {
736+
channelPool.close();
737+
} catch (RuntimeException e) {
738+
if (e.getCause() instanceof InterruptedException) {
739+
Thread.currentThread().interrupt();
740+
} else {
741+
throw e;
742+
}
743+
} finally {
744+
if (wasInterrupted) {
745+
Thread.currentThread().interrupt();
746+
}
747+
}
748+
733749
eventLoop.shutdownGracefully();
734750
}
735751
}

src/main/java/com/google/devtools/build/lib/runtime/BlockWaitingModule.java

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void afterCommand() throws AbruptExitException {
5151
try {
5252
executorService.awaitTermination(Long.MAX_VALUE, SECONDS);
5353
} catch (InterruptedException e) {
54+
executorService.shutdownNow();
5455
Thread.currentThread().interrupt();
5556
}
5657

0 commit comments

Comments
 (0)