Skip to content

Commit c1250b1

Browse files
committed
Replace use of deprecated ContextSnapshot methods
See gh-32813
1 parent 0ea7af7 commit c1250b1

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ReactiveTypeHandler.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
import java.util.concurrent.atomic.AtomicReference;
2727

2828
import io.micrometer.context.ContextSnapshot;
29+
import io.micrometer.context.ContextSnapshotFactory;
2930
import org.apache.commons.logging.Log;
3031
import org.apache.commons.logging.LogFactory;
3132
import org.reactivestreams.Publisher;
@@ -517,14 +518,16 @@ public ResolvableType getReturnType() {
517518

518519
private static class ContextSnapshotHelper {
519520

520-
@SuppressWarnings("deprecation")
521+
private static final ContextSnapshotFactory factory = ContextSnapshotFactory.builder().build();
522+
523+
@SuppressWarnings("ReactiveStreamsUnusedPublisher")
521524
public static Object writeReactorContext(Object returnValue) {
522525
if (Mono.class.isAssignableFrom(returnValue.getClass())) {
523-
ContextSnapshot snapshot = ContextSnapshot.captureAll();
526+
ContextSnapshot snapshot = factory.captureAll();
524527
return ((Mono<?>) returnValue).contextWrite(snapshot::updateContext);
525528
}
526529
else if (Flux.class.isAssignableFrom(returnValue.getClass())) {
527-
ContextSnapshot snapshot = ContextSnapshot.captureAll();
530+
ContextSnapshot snapshot = factory.captureAll();
528531
return ((Flux<?>) returnValue).contextWrite(snapshot::updateContext);
529532
}
530533
else {

0 commit comments

Comments
 (0)