spring-framework icon indicating copy to clipboard operation
spring-framework copied to clipboard

Document LocaleContextHolder inheritable behavior

Open cfcromn opened this issue 6 months ago • 1 comments

Closes #36687

This change documents that LocaleContextHolder's inheritable flag relies on JDK InheritableThreadLocal semantics, which only propagate values to newly created child threads at the time of their creation.

In thread pool environments where threads are reused across tasks, the context is not refreshed per task submission, so this mechanism is not suitable for per-task context propagation to reused threads.

The documentation now points users toward TaskDecorator for explicit per-task locale context propagation.

Verification:

  • ./gradlew :spring-context:compileJava
  • ./gradlew :spring-context:test --tests "org.springframework.context.i18n.LocaleContextHolderTests"

cfcromn avatar May 29 '26 00:05 cfcromn

Hi team, just checking whether this PR is aligned with the intended direction for #36687.

The change is intentionally limited to documenting the existing InheritableThreadLocal behavior and pointing users to TaskDecorator for per-task propagation in reused thread-pool scenarios.

Happy to adjust the wording or location if there is a preferred place for this documentation.

cfcromn avatar Jun 18 '26 15:06 cfcromn