Skip to content

5.0.0 to 5.1.4 changes status exception behaviour #373

Open
@m-miyano

Description

@m-miyano

Hello,

I tried to update from v5.0.0 to v5.1.4, I observed a change in the status code handling when an exception occurs.

My service uses streaming. Here's a snippet of the relevant code:

service MyService {
    rpc Streaming(stream MyRequest) returns (stream MyResponse) {}
}

In the context of onFailure, pass StatusRuntimeException to observer.onError.
simplified code snippet below:

override fun streaming(responseObserver: StreamObserver<MyResponse>): StreamObserver<MyRequest> {
    override fun onCompleted() {
        runCatching {
            // some processing
        }.onFailure {
            responseObserver.onError(
                Status.NOT_FOUND
                    .withCause(Exception("some exception"))
                    .asRuntimeException()) //to StatusRuntimeException
        }
    }
}

In v5.0.0

ERROR:
  Code: NOT_FOUND

In v5.1.4

ERROR:
  Code: INTERNAL

The issue below mentions a problem with StatusException, but the issue also occurs with StatusRuntimeException.
#371

It appears that the newly introduced passage through the failureHandlingSupport.closeCall method is causing the impact.

Boolean handled = Optional.ofNullable(EXCEPTION_HANDLED.get())
.map(AtomicBoolean::get)
.orElse(!exceptionHandled.compareAndSet(false, true));
if(null != status.getCause() && !handled){
failureHandlingSupport.closeCall(new GRpcRuntimeExceptionWrapper(status.getCause()), this, trailers);
}

If I've implemented something contrary to your intentions, please let me know.
Thank you always for your support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions