Skip to content

Forced StatusException conversion in ClientCalls.onClose() #634

@bong01

Description

@bong01

override fun onClose(status: Status, trailersMetadata: GrpcMetadata) {

In the current implementation of ClientCalls.onClose(), when a response from the server is not isOk and the exception is not a CancellationException, it forcibly converts any exception to StatusException (checked exception) before passing it to responses.close().
While Kotlin doesn't enforce checked exception handling, I'm curious if this conversion is intentional, especially in cases where the original exception is StatusRuntimeException.

Current behavior:

val cause = when {
    status.isOk -> null
    status.cause is CancellationException -> status.cause
    else -> status.asException(trailersMetadata)  // Always converts to StatusException
}

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