Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forced StatusException conversion in ClientCalls.onClose() #634

Open
bong01 opened this issue Feb 8, 2025 · 0 comments · May be fixed by #635
Open

Forced StatusException conversion in ClientCalls.onClose() #634

bong01 opened this issue Feb 8, 2025 · 0 comments · May be fixed by #635

Comments

@bong01
Copy link

bong01 commented Feb 8, 2025

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
}
@bong01 bong01 linked a pull request Feb 9, 2025 that will close this issue
@bong01 bong01 changed the title Forced StatusException conversion in ClientCalls.close() Forced StatusException conversion in ClientCalls.onClose() Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant