Skip to content

async server: need to ignore unary response msg if status is not OK #5969

@ejona86

Description

@ejona86

The expectation for unary responses is that the server will respond with an message or an error. If the server responds with a message and an error, the message should be thrown away. The async API currently would send the message. For unary responses, we should delay sending the response until the onComplete()/onError(). If onError() is called we should not send the message.

public void onNext(RespT response) {
if (cancelled) {
if (onCancelHandler == null) {
throw Status.CANCELLED.withDescription("call already cancelled").asRuntimeException();
}
return;
}
checkState(!aborted, "Stream was terminated by error, no further calls are allowed");
checkState(!completed, "Stream is already completed, no further calls are allowed");
if (!sentHeaders) {
call.sendHeaders(new Metadata());
sentHeaders = true;
}
call.sendMessage(response);

See #5968 and grpc/grpc#12824

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions