|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
26 | 26 | import java.util.concurrent.atomic.AtomicReference;
|
27 | 27 |
|
28 | 28 | import io.micrometer.context.ContextSnapshot;
|
| 29 | +import io.micrometer.context.ContextSnapshotFactory; |
29 | 30 | import org.apache.commons.logging.Log;
|
30 | 31 | import org.apache.commons.logging.LogFactory;
|
31 | 32 | import org.reactivestreams.Publisher;
|
@@ -517,14 +518,16 @@ public ResolvableType getReturnType() {
|
517 | 518 |
|
518 | 519 | private static class ContextSnapshotHelper {
|
519 | 520 |
|
520 |
| - @SuppressWarnings("deprecation") |
| 521 | + private static final ContextSnapshotFactory factory = ContextSnapshotFactory.builder().build(); |
| 522 | + |
| 523 | + @SuppressWarnings("ReactiveStreamsUnusedPublisher") |
521 | 524 | public static Object writeReactorContext(Object returnValue) {
|
522 | 525 | if (Mono.class.isAssignableFrom(returnValue.getClass())) {
|
523 |
| - ContextSnapshot snapshot = ContextSnapshot.captureAll(); |
| 526 | + ContextSnapshot snapshot = factory.captureAll(); |
524 | 527 | return ((Mono<?>) returnValue).contextWrite(snapshot::updateContext);
|
525 | 528 | }
|
526 | 529 | else if (Flux.class.isAssignableFrom(returnValue.getClass())) {
|
527 |
| - ContextSnapshot snapshot = ContextSnapshot.captureAll(); |
| 530 | + ContextSnapshot snapshot = factory.captureAll(); |
528 | 531 | return ((Flux<?>) returnValue).contextWrite(snapshot::updateContext);
|
529 | 532 | }
|
530 | 533 | else {
|
|
0 commit comments