From 898634f96add8e2933f77e08f2ee7ff83939fd09 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Sat, 13 Feb 2016 17:27:13 -0800 Subject: [PATCH] In blocking stubs, throw Status.CANCELLED on interruption This was already being done in one case, but should have been done for the other occurrances of InterruptedException. Before the RuntimeException is just asking to be a bug since application code will commonly only catch StatusRuntimeException. --- stub/src/main/java/io/grpc/stub/ClientCalls.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stub/src/main/java/io/grpc/stub/ClientCalls.java b/stub/src/main/java/io/grpc/stub/ClientCalls.java index 73fa3f2636..178265538b 100644 --- a/stub/src/main/java/io/grpc/stub/ClientCalls.java +++ b/stub/src/main/java/io/grpc/stub/ClientCalls.java @@ -135,7 +135,7 @@ public class ClientCalls { executor.waitAndDrain(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - throw new RuntimeException(e); + throw Status.CANCELLED.withCause(e).asRuntimeException(); } } return getUnchecked(responseFuture); @@ -436,7 +436,7 @@ public class ClientCalls { last = waitForNext(); } catch (InterruptedException ie) { Thread.interrupted(); - throw new RuntimeException(ie); + throw Status.CANCELLED.withCause(ie).asRuntimeException(); } } if (last instanceof Status) {