-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Add ThreadLocalAccessor for LocaleContext and RequestAttributes #32243
Conversation
ThreadLocalAccessor
for LocaleContext
and RequestAttributes
ThreadLocalAccessor
for LocaleContext
and RequestAttributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. Leaving some feedback to consider.
...context/src/main/java/org/springframework/context/i18n/LocaleContextThreadLocalAccessor.java
Outdated
Show resolved
Hide resolved
.../main/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessor.java
Outdated
Show resolved
Hide resolved
...context/src/main/java/org/springframework/context/i18n/LocaleContextThreadLocalAccessor.java
Outdated
Show resolved
Hide resolved
.../main/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessor.java
Outdated
Show resolved
Hide resolved
the option to opt-in to context propagation through the `ThreadLocalAccessor` implementations, | ||
`LocaleContextThreadLocalAccessor` and `RequestAttributesThreadLocalAccessor`. | ||
(They are not auto-registered by default.) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these implementations can be mentioned at the end of this section, after the scenarios are discussed. Something along the lines of..
The following ThreadLocalAccessor
implementations are provided out of the box:
LocaleContextThreadLocalAccessor
-- propagatesLocaleContext
via `LocalContetHolder.- ...
The above are not registered automatically. You will need to register them via ContextRegistry.getInstance()
on startup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this change. However, I still think this whole addition needs to move to end of the section. Otherwise it breaks up the flow, and the next paragraph "For other asynchronous handling scenarios..." is now referring to content that's further up.
@@ -0,0 +1,55 @@ | |||
/* | |||
* Copyright 2024-2024 the original author or authors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The copyright header must be 2002-2024
. This applies to other files as well.
* @author Tadaya Tsuyukubo | ||
*/ | ||
class LocaleContextThreadLocalAccessorTests { | ||
private final ContextRegistry registry = new ContextRegistry() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line required here
* A {@link ThreadLocalAccessor} to put and restore the current {@link LocaleContext}. | ||
* | ||
* @author Tadaya Tsuyukubo | ||
* @since 6.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use 6.2
for things introduced in the first release of a line.
import static org.mockito.Mockito.mock; | ||
|
||
/** | ||
* @author Tadaya Tsuyukubo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Tests for {@link RequestAttributesThreadLocalAccessor}.
latch.countDown(); | ||
}).start(); | ||
|
||
latch.await(10, TimeUnit.MILLISECONDS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems rather short to me.
e6967c2
to
6ab8517
Compare
Updated with the followings:
|
Add `ThreadLocalAccessor` implementations: - `LocaleThreadLocalAccessor` - `RequestAttributesThreadLocalAccessor` Closes spring-projectsgh-32112 Signed-off-by: Tadaya Tsuyukubo <[email protected]>
6ab8517
to
991b161
Compare
Add `ThreadLocalAccessor` implementations: - `LocaleThreadLocalAccessor` - `RequestAttributesThreadLocalAccessor` See gh-32243
Add
ThreadLocalAccessor
implementations:LocaleThreadLocalAccessor
RequestAttributesThreadLocalAccessor
Closes gh-32112