Add trailers to Status for BlockingResponseStream

This commit is contained in:
nmittler 2016-05-25 06:54:31 -07:00
parent 641cb357c6
commit 6e40edbc21
1 changed files with 6 additions and 3 deletions

View File

@ -41,6 +41,7 @@ import io.grpc.ClientCall;
import io.grpc.Metadata;
import io.grpc.MethodDescriptor;
import io.grpc.Status;
import io.grpc.StatusRuntimeException;
import java.util.Iterator;
import java.util.NoSuchElementException;
@ -437,8 +438,10 @@ public class ClientCalls {
throw Status.CANCELLED.withCause(ie).asRuntimeException();
}
}
if (last instanceof Status) {
throw ((Status) last).asRuntimeException();
if (last instanceof StatusRuntimeException) {
// Rethrow the exception with a new stacktrace.
StatusRuntimeException e = (StatusRuntimeException) last;
throw e.getStatus().asRuntimeException(e.getTrailers());
}
return last != this;
}
@ -482,7 +485,7 @@ public class ClientCalls {
if (status.isOk()) {
buffer.add(BlockingResponseStream.this);
} else {
buffer.add(status);
buffer.add(status.asRuntimeException(trailers));
}
done = true;
}