mirror of https://github.com/grpc/grpc-java.git
core: move exception to listener for RuntimeException, Error still throws
This commit is contained in:
parent
c9b02db276
commit
01ea67f5cf
|
|
@ -137,10 +137,11 @@ final class ServerCallImpl<ReqT, RespT> extends ServerCall<ReqT, RespT> {
|
|||
stream.flush();
|
||||
} catch (RuntimeException e) {
|
||||
close(Status.fromThrowable(e), new Metadata());
|
||||
} catch (Error e) {
|
||||
close(
|
||||
Status.CANCELLED.withDescription("Server sendMessage() failed with Error"),
|
||||
new Metadata());
|
||||
throw e;
|
||||
} catch (Throwable t) {
|
||||
close(Status.fromThrowable(t), new Metadata());
|
||||
throw new RuntimeException(t);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -158,12 +158,7 @@ public class ServerCallImplTest {
|
|||
call.sendHeaders(new Metadata());
|
||||
doThrow(new RuntimeException("bad")).when(stream).writeMessage(isA(InputStream.class));
|
||||
|
||||
try {
|
||||
call.sendMessage(1234L);
|
||||
fail();
|
||||
} catch (RuntimeException e) {
|
||||
// expected
|
||||
}
|
||||
call.sendMessage(1234L);
|
||||
|
||||
verify(stream).close(isA(Status.class), isA(Metadata.class));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue