/** * Returns the result of calling {@link Future#get()} interruptibly on a task known not to throw a * checked exception. * * <p>If interrupted, the interrupt is restored before throwing an exception.. * * @throws java.util.concurrent.CancellationException * if {@code get} throws a {@code CancellationException}. * @throws io.grpc.StatusRuntimeException if {@code get} throws an {@link ExecutionException} * or an {@link InterruptedException}. */ private static <V> V getUnchecked(Future<V> future) { try { return future.get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw Status.CANCELLED .withDescription("Call was interrupted") .withCause(e) .asRuntimeException(); } catch (ExecutionException e) { throw toStatusRuntimeException(e.getCause()); } }