Skip to content

Commit fd9cffd

Browse files
werktcopybara-github
authored andcommitted
Suppress interrupted status during pool closure
awaitTermination will throw InterruptedException if the interrupted status is set initially when it is called, even if no wait is required. Pool closure should not respect active interrupted status when shutting down and awaiting termination as a result of its call from executionPhaseEnding, which will occur during abnormal exits from ExecutionTool. Ignore this status initially and restore the flag upon exit of the factory close. An external interrupt which occurs during the awaitTermination will still trigger an InterruptedException, as expected. Fixes #13512 Closes #13521. PiperOrigin-RevId: 377006347
1 parent ecf6b18 commit fd9cffd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/main/java/com/google/devtools/build/lib/remote/grpc/ChannelConnectionFactory.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,20 @@ public <ReqT, RespT> ClientCall<ReqT, RespT> call(
4646

4747
@Override
4848
public void close() throws IOException {
49+
// Clear interrupted status to prevent failure to await, indicated with #13512
50+
boolean wasInterrupted = Thread.interrupted();
4951
// There is a bug (b/183340374) in gRPC that client doesn't try to close connections with
5052
// shutdown() if the channel received GO_AWAY frames. Using shutdownNow() here as a
5153
// workaround.
52-
channel.shutdownNow();
5354
try {
55+
channel.shutdownNow();
5456
channel.awaitTermination(Integer.MAX_VALUE, SECONDS);
5557
} catch (InterruptedException e) {
5658
throw new IOException(e.getMessage(), e);
59+
} finally {
60+
if (wasInterrupted) {
61+
Thread.currentThread().interrupt();
62+
}
5763
}
5864
}
5965

0 commit comments

Comments
 (0)