aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar Robert Gay <robert.gay@redfin.com>2018-08-02 06:28:57 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-08-02 06:30:48 -0700
commitdcd7c63d09e12fc3e2a9ca80b1422e4bcdd2740f (patch)
treed07c6ae7b275b24211b66768058505627c9749aa /src/main/java/com/google
parent77e4792a06ba5b3332a15b3069c30fb8f4ed5741 (diff)
Prevent errors on double-close in HttpBlobStore
Attempt to fix #5711, "java.util.concurrent.RejectedExecutionException: event executor terminated", by having `HttpBlobStore.close()` no-op when called more than once. I'm rolling a patched version of bazel for us internally based on 0.15.2. Should be able to say definitively in a couple days whether or not this addresses the issue, but it seems like it should (and @buchgr agrees). Closes #5725. PiperOrigin-RevId: 207089681
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/blobstore/http/HttpBlobStore.java16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/blobstore/http/HttpBlobStore.java b/src/main/java/com/google/devtools/build/lib/remote/blobstore/http/HttpBlobStore.java
index 0bcc68bd64..63f1a9d071 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/blobstore/http/HttpBlobStore.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/blobstore/http/HttpBlobStore.java
@@ -108,6 +108,11 @@ public final class HttpBlobStore implements SimpleBlobStore {
private final URI uri;
private final int timeoutMillis;
+ private final Object closeLock = new Object();
+
+ @GuardedBy("closeLock")
+ private boolean isClosed;
+
private final Object credentialsLock = new Object();
@GuardedBy("credentialsLock")
@@ -522,8 +527,15 @@ public final class HttpBlobStore implements SimpleBlobStore {
@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void close() {
- channelPool.close();
- eventLoop.shutdownGracefully();
+ synchronized (closeLock) {
+ if (isClosed) {
+ return;
+ }
+
+ isClosed = true;
+ channelPool.close();
+ eventLoop.shutdownGracefully();
+ }
}
private boolean cacheMiss(HttpResponseStatus status) {