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

Support StatusException in CoroutineContextServerInterceptor. #249

Conversation

hovinen
Copy link
Contributor

@hovinen hovinen commented Apr 19, 2021

Previously, there was no way for a subclass of CoroutineContextServerInterceptor to close a call and prevent further processing. The interceptor would unconditionally invoke the next handler in the chain unless prevented by an exception. If the coroutineContext method threw an exception, it would bubble up to the thread pool and show up in the logs as an error.

This change adds a handler for StatusException in CoroutineContextServerInterceptor to catch a StatusException and close the call with no further action.

Fixes #221

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Apr 19, 2021

CLA Signed

The committers are authorized under a signed CLA.

@hovinen hovinen force-pushed the support-status-exception-in-coroutine-context-server-interceptor branch from e61336a to e74cc82 Compare April 19, 2021 09:12
@jamesward jamesward requested a review from lowasser April 19, 2021 14:30
@jamesward jamesward added this to the 1.0.1 milestone Apr 19, 2021
Previously, there was no way for a subclass of CoroutineContextServerInterceptor to close a call and prevent further processing. The interceptor would unconditionally invoke the next handler in the chain unless prevented by an exception. If the coroutineContext method threw an exception, it would bubble up to the thread pool and show up in the logs as an error.

This change adds a handler for StatusException in CoroutineContextServerInterceptor to catch a StatusException and close the call with no further action.

Fixes grpc#221
@hovinen hovinen force-pushed the support-status-exception-in-coroutine-context-server-interceptor branch from e74cc82 to 734cb1c Compare April 20, 2021 08:49
@jamesward jamesward removed this from the 1.1.0 milestone Apr 29, 2021
@jamesward jamesward added this to the 1.2.0 milestone Oct 5, 2021
@jamesward
Copy link
Collaborator

Ping @hovinen - I want to get this in for the 1.2.0 release and it looks like we just need one more change.

@lowasser
Copy link
Collaborator

lowasser commented Oct 12, 2021

This works. I was imagining an object : ServerCall.Listener<ReqT> where every function threw, but this works fine too (arguably better).

@jamesward jamesward merged commit 9e98ca2 into grpc:master Oct 12, 2021
@jamesward
Copy link
Collaborator

Thanks @hovinen!

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 this pull request may close these issues.

How to close the call from a CoroutineContextServerInterceptor?
3 participants