Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@
* by any child threads spawned by the current thread if the
* {@code inheritable} flag is set to {@code true}.
*
* <p><b>Note:</b> The {@code inheritable} flag relies on JDK
* {@link java.lang.InheritableThreadLocal} semantics, which only propagates
* the context value to <em>newly created</em> 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; reused threads
* retain whatever value was inherited when they were originally created.
* This mechanism is therefore not suitable for per-task context propagation
* in thread pool environments. Instead, consider using a
* {@link org.springframework.core.task.TaskDecorator} that captures and
* restores the locale context around each task execution.
*
* <p>Used as a central holder for the current Locale in Spring,
* wherever necessary: for example, in MessageSourceAccessor.
* DispatcherServlet automatically exposes its current Locale here.
Expand All @@ -42,6 +53,7 @@
* @see LocaleContext
* @see org.springframework.context.support.MessageSourceAccessor
* @see org.springframework.web.servlet.DispatcherServlet
* @see org.springframework.core.task.TaskDecorator
*/
public final class LocaleContextHolder {

Expand Down Expand Up @@ -91,7 +103,9 @@ public static void setLocaleContext(@Nullable LocaleContext localeContext) {
* @param localeContext the current LocaleContext,
* or {@code null} to reset the thread-bound context
* @param inheritable whether to expose the LocaleContext as inheritable
* for child threads (using an {@link InheritableThreadLocal})
* for child threads (using an {@link InheritableThreadLocal}); note that
* this only propagates to newly created threads, not to threads reused
* in a thread pool &mdash; see the class-level note for details
* @see SimpleLocaleContext
* @see SimpleTimeZoneAwareLocaleContext
*/
Expand Down