Skip to content

Proper handling of server stubs that throw? #2429

Closed
@jhspaybar

Description

@jhspaybar

Please answer these questions before submitting your issue.

What version of gRPC are you using?

1.0.1

What JVM are you using (java -version)?

1.8

What did you do?

If possible, provide a recipe for reproducing the error.
throw new RuntimeException() in any server implementation of an rpc defined in your proto

What did you expect to see?

client gets UNKNOWN, close or cancel to eventually be called in the interceptor chain on the server

What did you see instead?

client gets UNKNOWN, and my interceptor chain stops executing in the halfClose (for Unary requests/responses).

I'm wondering, if some interceptors want/need to do cleanup to do things like emit metrics, modify logging MDC in thread locals and such, what should I expect here and be doing? Is it reasonable to have an exception mapping interceptor that is the last one called right before the actual implementation and if it catches any exception translate it into a close(Status.UNKNOWN, new Metadata()) ? Should I instead have every interceptor catch exceptions in onHalfClose and onMessage and then bubble it after they do their personal cleanup? We had up to this point kept our cleanup logic isolated to close(...) and onCancel().

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