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

Propagate ThreadLocals for non-Reactor upstream sources #3418

Merged
merged 3 commits into from Apr 3, 2023

Conversation

chemicL
Copy link
Member

@chemicL chemicL commented Mar 28, 2023

Factory methods for creating Flux and Mono from non-Reactor sources now restore ThreadLocal values when Hooks.enableAutomaticContextPropagation() was called in the following cases:

  • Flux.from(Publisher)
  • Mono.from(Publisher)
  • Mono.fromDirect(Publisher)
  • Mono.fromFuture(CompletableFuture)
  • Mono.fromCompletionStage(CompletionStage)

and relevant overloads.

Fixes #3366.

Factory methods for creating `Flux` and `Mono` from non-Reactor sources
now restore `ThreadLocal` values when `Hooks.enableAutomaticContextPropagation()`
was called in the following cases:

* Flux.from(Publisher)
* Mono.from(Publisher)
* Mono.fromDirect(Publisher)
* Mono.fromFuture(CompletableFuture)
* Mono.fromCompletionStage(CompletionStage)

and relevant overrides.

Fixes #3366.
@chemicL chemicL added type/enhancement A general enhancement area/context This issue is related to the Context area/observability labels Mar 28, 2023
@chemicL chemicL added this to the 3.5.5 milestone Mar 28, 2023
@chemicL chemicL self-assigned this Mar 28, 2023
Comment on lines -65 to -66
Fuseable,
QueueSubscription<T>,
Copy link
Member Author

Choose a reason for hiding this comment

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

Note, MonoCompletionStage also has Fuseable removed. They are not needed, as the fusion support is NONE. And it makes the subscriber wrapping to the restoring subscriber possible (it is not Fuseable).

@chemicL chemicL marked this pull request as ready for review March 30, 2023 11:51
@chemicL chemicL requested a review from a team as a code owner March 30, 2023 11:51
@chemicL
Copy link
Member Author

chemicL commented Apr 3, 2023

Verified against the reproducer provided in spring-projects/spring-boot#34374 - trace info is present with this branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/context This issue is related to the Context area/observability type/enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ThreadLocal values lost after non-Reactor upstream sources continue execution
2 participants