|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2019 the original author or authors. |
| 2 | + * Copyright 2002-2023 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.
|
@@ -48,33 +48,35 @@ public class ServerWebExchangeContextFilter implements WebFilter {
|
48 | 48 | @Override
|
49 | 49 | public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
50 | 50 | return chain.filter(exchange)
|
51 |
| - .contextWrite(cxt -> cxt.put(EXCHANGE_CONTEXT_ATTRIBUTE, exchange)); |
| 51 | + .contextWrite(context -> context.put(EXCHANGE_CONTEXT_ATTRIBUTE, exchange)); |
52 | 52 | }
|
53 | 53 |
|
54 | 54 |
|
55 | 55 | /**
|
56 |
| - * Access the {@link ServerWebExchange} from the Reactor Context, if available, |
57 |
| - * which is if {@link ServerWebExchangeContextFilter} is configured for use |
58 |
| - * and the give context was obtained from a request processing chain. |
59 |
| - * @param context the context in which to access the exchange |
60 |
| - * @return the exchange |
| 56 | + * Access the {@link ServerWebExchange} from a Reactor {@link ContextView}, |
| 57 | + * if available, which is generally the case when |
| 58 | + * {@link ServerWebExchangeContextFilter} is present in the filter chain. |
| 59 | + * @param contextView the contextView to get the exchange from |
| 60 | + * @return an {@link Optional} with the exchange if found |
| 61 | + * @since 6.0.6 |
61 | 62 | */
|
62 |
| - public static Optional<ServerWebExchange> getExchange(ContextView context) { |
63 |
| - return context.getOrEmpty(EXCHANGE_CONTEXT_ATTRIBUTE); |
| 63 | + public static Optional<ServerWebExchange> getExchange(ContextView contextView) { |
| 64 | + return contextView.getOrEmpty(EXCHANGE_CONTEXT_ATTRIBUTE); |
64 | 65 | }
|
65 | 66 |
|
66 |
| - |
67 | 67 | /**
|
68 |
| - * Access the {@link ServerWebExchange} from the Reactor Context, if available, |
69 |
| - * which is if {@link ServerWebExchangeContextFilter} is configured for use |
70 |
| - * and the give context was obtained from a request processing chain. |
71 |
| - * @param context the context in which to access the exchange |
72 |
| - * @return the exchange |
73 |
| - * @deprecated use {@link #getExchange(ContextView)} |
| 68 | + * Access the {@link ServerWebExchange} from a Reactor {@link Context}, |
| 69 | + * if available, which is generally the case when |
| 70 | + * {@link ServerWebExchangeContextFilter} is present in the filter chain. |
| 71 | + * @param context the context to get the exchange from |
| 72 | + * @return an {@link Optional} with the exchange if found |
| 73 | + * @deprecated in favor of using {@link #getExchange(ContextView)} which |
| 74 | + * accepts a {@link ContextView} instead of {@link Context}, reflecting the |
| 75 | + * fact that the {@code ContextView} is needed only for reading. |
74 | 76 | */
|
75 |
| - @Deprecated(since = "6.0.6") |
| 77 | + @Deprecated(since = "6.0.6", forRemoval = true) |
76 | 78 | public static Optional<ServerWebExchange> get(Context context) {
|
77 |
| - return getExchange(context); |
| 79 | + return context.getOrEmpty(EXCHANGE_CONTEXT_ATTRIBUTE); |
78 | 80 | }
|
79 | 81 |
|
80 | 82 | }
|
0 commit comments