apple / servicetalk

A networking framework that evolves with your application
https://docs.servicetalk.io
Apache License 2.0
915 stars 180 forks source link

Improve `CancellationException` #3039

Closed idelpivnitskiy closed 1 month ago

idelpivnitskiy commented 1 month ago

Motivation:

  1. H2ClientParentConnectionContext.StacklessCancellationException was reused by SpliceFlatStreamToMetaSingle, which created a false impression in logs that this exception is related to HTTP/2.
  2. We should capture the Subscriber's stack-trace for CancellationException in BeforeFinallyHttpOperator instead of a netty stack-trace, it will help to debug paths that subscribe to the payload post cancel.

Modifications:

  1. Make H2ClientParentConnectionContext.StacklessCancellationException a top-level class.
  2. Wrap CancellationException with Publisher.defer(...) in BeforeFinallyHttpOperator.
  3. Add an exception message in DefaultBlockingIterableProcessor.

Result:

Easier for users to reason about received CancellationException.