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

BeforeFinallyHttpOperator: support re-subscribe to the message body #2409

Merged
merged 3 commits into from
Oct 27, 2022

Conversation

idelpivnitskiy
Copy link
Member

@idelpivnitskiy idelpivnitskiy commented Oct 26, 2022

Motivation:

BeforeFinallyHttpOperator has a single state inside ResponseCompletionSubscriber that is shared between Single and Publisher of the message body. If users re-subscribe to the message body, the state is already in TERMINATED position and does not propagate signals.

Modifications:

  • Move message body processing logic into a new MessageBodySubscriber class;
  • Each subscribe operation creates a new MessageBodySubscriber and their states are managed independently;
  • Improve IdleTimeoutConnectionFilterTest to always create a new response object (otherwise, the response payload body can be transformed multiple times);

Result:

Users of BeforeFinallyOperator always see all terminal events, even for re-subscribe. Terminal signal will always be delivered to the second subscriber, even when discardEventsAfterCancel is set.

Motivation:

`BeforeFinallyHttpOperator` has a single `state` inside
`ResponseCompletionSubscriber` that is shared between `Single` and
`Publisher` of the message body. If users re-subscribe to the message
body, the state is already in `TERMINATED` position and does not
propagate signals.

Modifications:

- Move message body processing logic into a new `MessageBodySubscriber`
class;
- Each subscribe operation creates a new `MessageBodySubscriber` and
their states are managed independently;

Result:

Users of `BeforeFinallyOperator` always see all terminal events, even
for re-subscribe. Terminal signal will always be delivered to the
second subscriber, even when `discardEventsAfterCancel` is set.
Copy link
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

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

IdleTimeoutConnectionFilterTest.twoConcurrentRequests() test failure

@idelpivnitskiy
Copy link
Member Author

The problem was in the test, it reused a response object which resulted in applying transform on the payload body twice.

@idelpivnitskiy idelpivnitskiy merged commit 5d22672 into apple:main Oct 27, 2022
@idelpivnitskiy idelpivnitskiy deleted the MessageBodySubscriber branch October 27, 2022 04:25
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.

2 participants