Skip to content

Commit f7548a8

Browse files
committed
Deprecations related to reactive type support in 5.0
Issue: SPR-15365
1 parent e0fe7cd commit f7548a8

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

spring-web/src/main/java/org/springframework/web/method/support/AsyncHandlerMethodReturnValueHandler.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,15 @@
1919
import org.springframework.core.MethodParameter;
2020

2121
/**
22-
* A {@link HandlerMethodReturnValueHandler} that handles return values that
23-
* represent asynchronous computation. Such handlers need to be invoked with
24-
* precedence over other handlers that might otherwise match the return value
25-
* type: e.g. a method that returns a Promise type that is also annotated with
26-
* {@code @ResponseBody}.
22+
* A return value handler that supports async types. Such return value types
23+
* need to be handled with priority so the async value can be "unwrapped".
2724
*
28-
* <p>In {@link #handleReturnValue}, implementations of this class should create
29-
* a {@link org.springframework.web.context.request.async.DeferredResult} or
30-
* adapt to it and then invoke {@code WebAsyncManager} to start async processing.
31-
* For example:
32-
* <pre>
33-
* DeferredResult<?> deferredResult = (DeferredResult<?>) returnValue;
34-
* WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(deferredResult, mavContainer);
35-
* </pre>
25+
* <p><strong>Note: </strong> implementing this contract is not required but it
26+
* should be implemented when the handler needs to be prioritized ahead of others.
27+
* For example custom (async) handlers, by default ordered after built-in
28+
* handlers, should take precedence over {@code @ResponseBody} or
29+
* {@code @ModelAttribute} handling, which should occur once the async value is
30+
* ready.
3631
*
3732
* @author Rossen Stoyanchev
3833
* @since 4.2

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@
2323
*
2424
* @author Rossen Stoyanchev
2525
* @since 4.3
26+
*
27+
* @deprecated in 4.3.8 since 5.0 adds first-class support for reactive type
28+
* return values from Spring MVC controller methods based on the pluggable
29+
* {@code ReactiveAdapterRegistry} mechanism. Yet another alternative would
30+
* be to implement a custom
31+
* {@link org.springframework.web.method.support.AsyncHandlerMethodReturnValueHandler}.
2632
*/
33+
@Deprecated
2734
public interface DeferredResultAdapter {
2835

2936
/**

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* @author Rossen Stoyanchev
4242
* @since 3.2
4343
*/
44+
@SuppressWarnings("deprecation")
4445
public class DeferredResultMethodReturnValueHandler implements AsyncHandlerMethodReturnValueHandler {
4546

4647
private final Map<Class<?>, DeferredResultAdapter> adapterMap;
@@ -61,7 +62,9 @@ public DeferredResultMethodReturnValueHandler() {
6162
* <p>By default the map contains adapters for {@code DeferredResult}, which
6263
* simply downcasts, {@link ListenableFuture}, and {@link CompletionStage}.
6364
* @return the map of adapters
65+
* @deprecated in 4.3.8, see comments on {@link DeferredResultAdapter}
6466
*/
67+
@Deprecated
6568
public Map<Class<?>, DeferredResultAdapter> getAdapterMap() {
6669
return this.adapterMap;
6770
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@
2323
*
2424
* @author Rossen Stoyanchev
2525
* @since 4.3
26+
*
27+
* @deprecated in 4.3.8 since 5.0 adds first-class support for reactive type
28+
* return values from Spring MVC controller methods based on the pluggable
29+
* {@code ReactiveAdapterRegistry} mechanism.
2630
*/
31+
@Deprecated
2732
public interface ResponseBodyEmitterAdapter {
2833

2934
/**

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
* @author Rossen Stoyanchev
5353
* @since 4.2
5454
*/
55+
@SuppressWarnings("deprecation")
5556
public class ResponseBodyEmitterReturnValueHandler implements AsyncHandlerMethodReturnValueHandler {
5657

5758
private static final Log logger = LogFactory.getLog(ResponseBodyEmitterReturnValueHandler.class);
@@ -75,7 +76,9 @@ public ResponseBodyEmitterReturnValueHandler(List<HttpMessageConverter<?>> messa
7576
* By default the map contains a single adapter {@code ResponseBodyEmitter}
7677
* that simply downcasts the return value.
7778
* @return the map of adapters
79+
* @deprecated in 4.3.8, see comments on {@link ResponseBodyEmitterAdapter}
7880
*/
81+
@Deprecated
7982
public Map<Class<?>, ResponseBodyEmitterAdapter> getAdapterMap() {
8083
return this.adapterMap;
8184
}

0 commit comments

Comments
 (0)