Polish "Add ThreadLocalAccessor for LocaleContext and RequestAttributes"
See gh-32243
This commit is contained in:
@@ -19,8 +19,10 @@ package org.springframework.context.i18n;
|
||||
import io.micrometer.context.ThreadLocalAccessor;
|
||||
|
||||
/**
|
||||
* Adapt {@link LocaleContextHolder} to the {@link ThreadLocalAccessor} contract to assist
|
||||
* the Micrometer Context Propagation library with {@link LocaleContext} propagation.
|
||||
* Adapt {@link LocaleContextHolder} to the {@link ThreadLocalAccessor} contract
|
||||
* to assist the Micrometer Context Propagation library with {@link LocaleContext}
|
||||
* propagation.
|
||||
*
|
||||
* @author Tadaya Tsuyukubo
|
||||
* @since 6.2
|
||||
*/
|
||||
|
||||
@@ -19,8 +19,10 @@ package org.springframework.web.context.request;
|
||||
import io.micrometer.context.ThreadLocalAccessor;
|
||||
|
||||
/**
|
||||
* Adapt {@link RequestContextHolder} to the {@link ThreadLocalAccessor} contract to assist
|
||||
* the Micrometer Context Propagation library with {@link RequestAttributes} propagation.
|
||||
* Adapt {@link RequestContextHolder} to the {@link ThreadLocalAccessor} contract
|
||||
* to assist the Micrometer Context Propagation library with
|
||||
* {@link RequestAttributes} propagation.
|
||||
*
|
||||
* @author Tadaya Tsuyukubo
|
||||
* @since 6.2
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.stream.Stream;
|
||||
|
||||
import io.micrometer.context.ContextRegistry;
|
||||
import io.micrometer.context.ContextSnapshot;
|
||||
import io.micrometer.context.ContextSnapshot.Scope;
|
||||
import io.micrometer.context.ContextSnapshotFactory;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
@@ -51,6 +52,7 @@ class RequestAttributesThreadLocalAccessorTests {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource
|
||||
@SuppressWarnings({ "try", "unused" })
|
||||
void propagation(@Nullable RequestAttributes previous, RequestAttributes current) throws Exception {
|
||||
RequestContextHolder.setRequestAttributes(current);
|
||||
ContextSnapshot snapshot = ContextSnapshotFactory.builder()
|
||||
@@ -64,7 +66,7 @@ class RequestAttributesThreadLocalAccessorTests {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
new Thread(() -> {
|
||||
RequestContextHolder.setRequestAttributes(previous);
|
||||
try (ContextSnapshot.Scope scope = snapshot.setThreadLocals()) {
|
||||
try (Scope scope = snapshot.setThreadLocals()) {
|
||||
currentHolder.set(RequestContextHolder.getRequestAttributes());
|
||||
}
|
||||
previousHolder.set(RequestContextHolder.getRequestAttributes());
|
||||
|
||||
Reference in New Issue
Block a user