Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion binder/src/main/java/io/grpc/binder/internal/Outbound.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,9 @@ protected final void sendInternal() throws StatusException {
transport.sendTransaction(callId, parcel);
statsTraceContext.outboundWireSize(dataSize);
statsTraceContext.outboundUncompressedSize(dataSize);
} catch (IOException e) {
} catch (IOException | RuntimeException e) {
// Checked IO failures and unchecked application serialization failures (for example
// Parcelable, metadata marshaller, or InputStream) both end the call. Do not catch Error.
throw Status.INTERNAL.withCause(e).asException();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,31 @@ public void msgFragmentsDeliveredToClientOutOfOrder() throws Exception {
assertThat(methodDescriptor.parseResponse(msg)).isEqualTo(largeMessage);
}

@Test
public void uncheckedSerializationFailureClosesClientStream() throws Exception {
// Unchecked serialization failures must close the call, same as IOException.
server.start(serverListener);
client = newClientTransport(server);
startTransport(client, mockClientTransportListener);

RuntimeException failure = new IllegalStateException("serialization");
ClientStreamListenerBase listener = new ClientStreamListenerBase();
ClientStream stream =
client.newStream(methodDescriptor, new Metadata(), CallOptions.DEFAULT, noopTracers);
stream.start(listener);
stream.writeMessage(
new InputStream() {
@Override
public int read() {
throw failure;
}
});

Status status = listener.awaitClose(TIMEOUT_MS, MILLISECONDS);
assertAbout(status()).that(status).hasCode(Status.Code.INTERNAL);
assertThat(status.getCause()).isSameInstanceAs(failure);
}

private static OneWayBinderProxy takeNextBinder(
BlockingBinderDecorator<OneWayBinderProxy> decorator) throws InterruptedException {
OneWayBinderProxy proxy = decorator.takeNextRequest(TIMEOUT_MS, MILLISECONDS);
Expand Down
Loading