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

GH-9259: Fix Reactor context propagation on reactive reply #9284

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

artembilan
Copy link
Member

Fixes: #9259

The Mono.toFuture() does not propagate context to thread locals of the CompletableFuture consumer. See MonoToCompletableFuture

  • Fix AbstractMessageProducingHandler to convert reply Mono to CompletableFuture manually. Use doOnEach() and set thread locals from the Reactor context manually around replyFuture.complete()/completeExceptionally()
  • Add respective unit test into WebFluxObservationPropagationTests to ensure that same trace is used in downstream endpoints after WebFlux client reply

Auto-cherry-pick to 6.3.x & 6.2.x

…eply

Fixes: spring-projects#9259

The `Mono.toFuture()` does not propagate context to thread locals of the `CompletableFuture` consumer.
See `MonoToCompletableFuture`

* Fix `AbstractMessageProducingHandler` to convert reply `Mono` to `CompletableFuture` manually.
Use `doOnEach()` and set thread locals from the Reactor context manually around `replyFuture.complete()/completeExceptionally()`
* Add respective unit test into `WebFluxObservationPropagationTests` to ensure that same trace is used in downstream endpoints after WebFlux client reply

**Auto-cherry-pick to `6.3.x` & `6.2.x`**
@artembilan artembilan requested a review from sobychacko June 28, 2024 16:13
@sobychacko sobychacko merged commit 4a77dbc into spring-projects:main Jun 28, 2024
2 of 3 checks passed
spring-builds pushed a commit that referenced this pull request Jun 28, 2024
Fixes: #9259

The `Mono.toFuture()` does not propagate context to thread locals of the `CompletableFuture` consumer.
See `MonoToCompletableFuture`

* Fix `AbstractMessageProducingHandler` to convert reply `Mono` to `CompletableFuture` manually.
Use `doOnEach()` and set thread locals from the Reactor context manually around `replyFuture.complete()/completeExceptionally()`
* Add respective unit test into `WebFluxObservationPropagationTests` to ensure that same trace is used in downstream endpoints after WebFlux client reply

(cherry picked from commit 4a77dbc)
spring-builds pushed a commit that referenced this pull request Jun 28, 2024
Fixes: #9259

The `Mono.toFuture()` does not propagate context to thread locals of the `CompletableFuture` consumer.
See `MonoToCompletableFuture`

* Fix `AbstractMessageProducingHandler` to convert reply `Mono` to `CompletableFuture` manually.
Use `doOnEach()` and set thread locals from the Reactor context manually around `replyFuture.complete()/completeExceptionally()`
* Add respective unit test into `WebFluxObservationPropagationTests` to ensure that same trace is used in downstream endpoints after WebFlux client reply

(cherry picked from commit 4a77dbc)
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.

Restore ReactorContext into Imperative Processing
2 participants