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

Improve CancellationException #3039

Merged
merged 3 commits into from
Aug 13, 2024

Conversation

idelpivnitskiy
Copy link
Member

@idelpivnitskiy idelpivnitskiy commented Aug 9, 2024

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.

Motivation:

1. `H2ClientParentConnectionContext.StacklessCancellationException` was
reused by `SpliceFlatStreamToMetaSingle`, which created a false
impression in logs that this exception is related to HTTP/2.
2. There is not much value in a stacktrace for `CancellationException`
in `BeforeFinallyHttpOperator`.

Modifications:

1. Make `H2ClientParentConnectionContext.StacklessCancellationException`
a top level class.
2. Create a `StacklessCancellationException` in http-utils module for
`BeforeFinallyHttpOperator`.
3. Add exception message in `DefaultBlockingIterableProcessor`.

Result:

Easier for users to reason about received `CancellationException`.
@idelpivnitskiy idelpivnitskiy self-assigned this Aug 9, 2024

import java.util.concurrent.CancellationException;

final class StacklessCancellationException extends CancellationException {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure if it's worth making it public in a module like concurrent-internal and created a copy for now. Can move if someone prefers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels a bit confusing to have the same exception in two different places, especially since http-netty depends on utils?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I changed my mind. It's worth capturing the full stack-trace if we capture the Subscriber's stack-trace instead of the netty transport stack-trace. Updated PR

@idelpivnitskiy idelpivnitskiy requested a review from daschl August 12, 2024 18:06
@idelpivnitskiy idelpivnitskiy merged commit 2f2bf85 into apple:main Aug 13, 2024
11 checks passed
@idelpivnitskiy idelpivnitskiy deleted the CancellationException branch August 13, 2024 18:03
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.

4 participants