Switch from INTERNAL to CANCELLED for InterruptedException

This commit is contained in:
Louis Ryan 2015-12-02 15:28:13 -08:00
parent e0ea1a10fc
commit 7f2678a332
1 changed files with 6 additions and 5 deletions

View File

@ -140,18 +140,19 @@ public class ClientCalls {
* Returns the result of calling {@link Future#get()} interruptably on a task known not to throw a
* checked exception.
*
* <p>If interrupted, the interrupt is restored before throwing a {@code RuntimeException}.
* <p>If interrupted, the interrupt is restored before throwing an exception..
*
* @throws RuntimeException if {@code get} is interrupted
* @throws CancellationException if {@code get} throws a {@code CancellationException}
* @throws StatusRuntimeException if {@code get} throws an {@code ExecutionException}
* @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 new RuntimeException(e);
throw Status.CANCELLED.withCause(e).asRuntimeException();
} catch (ExecutionException e) {
throw Status.fromThrowable(e).asRuntimeException();
}