spring-framework/spring-core/src
Brian Clozel f5a356c9c6 Add ContextPropagatingTaskDecorator
Prior to this commit, `@Async` and `@EventListener` annotated methods
would lose the the logging and observation contexts whenever their
execution was scheduled on a different Thread.

The Context Propagation library supports this use case and can propagate
context values in ThreadLocals, Reactor Context and more.

This commit introduces a new `TaskDecorator` implementation that
leverages the Context Propagation library. When configured on a
`TaskExecutor`, this allows to properly propagate context value through
the execution of the task.

This implementation is completely optional and requires the
"io.micrometer:context-propagation" library on the classpath. Enabling
this feature must be done consciously and sometimes selectively, as
context propagation introduces some overhead.

Closes gh-31130
2023-08-29 11:21:47 +02:00
..
jmh/java/org/springframework Polish "Improve performance of CompositePropertySource#getPropertyNames" 2023-08-26 17:46:19 +02:00
main Add ContextPropagatingTaskDecorator 2023-08-29 11:21:47 +02:00
test Add ContextPropagatingTaskDecorator 2023-08-29 11:21:47 +02:00
testFixtures/java/org/springframework/core/testfixture Polishing 2023-07-19 01:25:20 +02:00