Don't throw runtime exception on interruption - since we know the future is already done, we should leave the thread in an interrupted state and proceed. This fixes a blaze crash when a 'genquery' execution is interrupted at the right time.
@@ -24,7 +24,6 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.devtools.build.lib.query2.engine.QueryEnvironment.QueryTaskCallable;
import com.google.devtools.build.lib.query2.engine.QueryEnvironment.QueryTaskFuture;
-import com.google.devtools.build.lib.util.Preconditions;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
@@ -84,10 +83,9 @@ public abstract class AbstractQueryEnvironment<T> implements QueryEnvironment<T>
@Override
public T getIfSuccessful() {
- Preconditions.checkState(delegate.isDone());
try {
- return delegate.get();
- } catch (CancellationException | InterruptedException | ExecutionException e) {
+ return Futures.getDone(delegate);
+ } catch (CancellationException | ExecutionException e) {
throw new IllegalStateException(e);
}
}
