Skip to content

Commit fb8402f

Browse files
committed
stub: Avoid double-wrapping status
780b269 caused all failures for blocked unary stubs to have a StatusRuntimeException as the cause of the StatusRuntimeException, with the two exceptions having almost the same status.
1 parent 1775ab3 commit fb8402f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

stub/src/main/java/io/grpc/stub/ClientCalls.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ private static StatusRuntimeException toStatusRuntimeException(Throwable t) {
224224
// If we have an embedded status, use it and replace the cause
225225
if (cause instanceof StatusException) {
226226
StatusException se = (StatusException) cause;
227-
return new StatusRuntimeException(se.getStatus().withCause(t), se.getTrailers());
227+
return new StatusRuntimeException(se.getStatus(), se.getTrailers());
228228
} else if (cause instanceof StatusRuntimeException) {
229229
StatusRuntimeException se = (StatusRuntimeException) cause;
230-
return new StatusRuntimeException(se.getStatus().withCause(t), se.getTrailers());
230+
return new StatusRuntimeException(se.getStatus(), se.getTrailers());
231231
}
232232
cause = cause.getCause();
233233
}

stub/src/test/java/io/grpc/stub/ClientCallsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public Void answer(InvocationOnMock in) throws Throwable {
139139
@Test
140140
public void unaryBlockingCallFailed() throws Exception {
141141
Integer req = 2;
142-
final Status status = Status.INTERNAL;
142+
final Status status = Status.INTERNAL.withDescription("Unique status");
143143
final Metadata trailers = new Metadata();
144144

145145
doAnswer(new Answer<Void>() {
@@ -156,7 +156,7 @@ public Void answer(InvocationOnMock in) throws Throwable {
156156
ClientCalls.blockingUnaryCall(call, req);
157157
fail("Should fail");
158158
} catch (StatusRuntimeException e) {
159-
assertSame(status.getCode(), e.getStatus().getCode());
159+
assertSame(status, e.getStatus());
160160
assertSame(trailers, e.getTrailers());
161161
}
162162
}

0 commit comments

Comments
 (0)