From 74b5d29c8a98ac693870a22be6a63ad12d56e378 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 1 Jul 2015 16:32:04 -0700 Subject: [PATCH] Improve Exception backtrace for blocked streaming Delaying creating the exception produces a much more useful exception. The status code, description, and exception type are all identical. The only difference in the backtrace. --- stub/src/main/java/io/grpc/stub/ClientCalls.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stub/src/main/java/io/grpc/stub/ClientCalls.java b/stub/src/main/java/io/grpc/stub/ClientCalls.java index 5e28f273b8..03a6409d0f 100644 --- a/stub/src/main/java/io/grpc/stub/ClientCalls.java +++ b/stub/src/main/java/io/grpc/stub/ClientCalls.java @@ -370,8 +370,8 @@ public class ClientCalls { Thread.interrupted(); throw new RuntimeException(ie); } - if (last instanceof Throwable) { - throw Throwables.propagate((Throwable) last); + if (last instanceof Status) { + throw ((Status) last).asRuntimeException(); } return last != this; } @@ -415,7 +415,7 @@ public class ClientCalls { if (status.isOk()) { buffer.add(BlockingResponseStream.this); } else { - buffer.add(status.asRuntimeException()); + buffer.add(status); } done = true; }