Skip to content

Commit aef4b21

Browse files
committed
Polish "Add ThreadLocalAccessor for LocaleContext and RequestAttributes"
See gh-32243
1 parent 5bd1c1f commit aef4b21

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

spring-context/src/main/java/org/springframework/context/i18n/LocaleContextThreadLocalAccessor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import io.micrometer.context.ThreadLocalAccessor;
2020

2121
/**
22-
* Adapt {@link LocaleContextHolder} to the {@link ThreadLocalAccessor} contract to assist
23-
* the Micrometer Context Propagation library with {@link LocaleContext} propagation.
22+
* Adapt {@link LocaleContextHolder} to the {@link ThreadLocalAccessor} contract
23+
* to assist the Micrometer Context Propagation library with {@link LocaleContext}
24+
* propagation.
25+
*
2426
* @author Tadaya Tsuyukubo
2527
* @since 6.2
2628
*/

spring-web/src/main/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessor.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import io.micrometer.context.ThreadLocalAccessor;
2020

2121
/**
22-
* Adapt {@link RequestContextHolder} to the {@link ThreadLocalAccessor} contract to assist
23-
* the Micrometer Context Propagation library with {@link RequestAttributes} propagation.
22+
* Adapt {@link RequestContextHolder} to the {@link ThreadLocalAccessor} contract
23+
* to assist the Micrometer Context Propagation library with
24+
* {@link RequestAttributes} propagation.
25+
*
2426
* @author Tadaya Tsuyukubo
2527
* @since 6.2
2628
*/

spring-web/src/test/java/org/springframework/web/context/request/RequestAttributesThreadLocalAccessorTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import io.micrometer.context.ContextRegistry;
2525
import io.micrometer.context.ContextSnapshot;
26+
import io.micrometer.context.ContextSnapshot.Scope;
2627
import io.micrometer.context.ContextSnapshotFactory;
2728
import org.junit.jupiter.api.AfterEach;
2829
import org.junit.jupiter.params.ParameterizedTest;
@@ -51,6 +52,7 @@ void cleanUp() {
5152

5253
@ParameterizedTest
5354
@MethodSource
55+
@SuppressWarnings({ "try", "unused" })
5456
void propagation(@Nullable RequestAttributes previous, RequestAttributes current) throws Exception {
5557
RequestContextHolder.setRequestAttributes(current);
5658
ContextSnapshot snapshot = ContextSnapshotFactory.builder()
@@ -64,7 +66,7 @@ void propagation(@Nullable RequestAttributes previous, RequestAttributes current
6466
CountDownLatch latch = new CountDownLatch(1);
6567
new Thread(() -> {
6668
RequestContextHolder.setRequestAttributes(previous);
67-
try (ContextSnapshot.Scope scope = snapshot.setThreadLocals()) {
69+
try (Scope scope = snapshot.setThreadLocals()) {
6870
currentHolder.set(RequestContextHolder.getRequestAttributes());
6971
}
7072
previousHolder.set(RequestContextHolder.getRequestAttributes());

0 commit comments

Comments
 (0)