-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Closed
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement
Milestone
Description
Thomas Darimont opened SPR-13128 and commented
Currently @Async
annotated methods support to return Future<> result wrappers via AsyncResult<> it would be great if we would support CompletableFuture here as well.
I created a small example that adds the necessary functionality to AsyncExecutionInterceptor
.
Usage:
@Async
public <T> CompletableFuture<T> asyncOperation(T input) {
System.out.println("working...");
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(5));
System.out.println("done.");
return CompletableFuture.completedFuture(input);
}
Consumer:
service.asyncOperation("test").thenAccept(System.out::println);
Reference URL: https://gist.github.com/thomasdarimont/197e92e537554634adbd
Issue Links:
- DATACMNS-714 Add support for CompletableFuture as query method return type on Spring 4.2 ("is depended on by")
- Support CompletableFuture as return value in @MessageMapping handlers [SPR-12207] #16821 Support CompletableFuture as return value in
@MessageMapping
handlers - Support CompletableFuture as alternative to DeferredResult in MVC [SPR-12597] #17198 Support CompletableFuture as alternative to DeferredResult in MVC
- INT-3724 Please add support for CompletableFuture in Asynchronous Gateways
- DATACMNS-712 Support CompletableFuture as repository return type
- Document supported return types for @Async methods [SPR-14881] #19447 Document supported return types for
@Async
methods
Referenced from: commits dd4bc63, c41779f, 581ab18
0 votes, 7 watchers
Metadata
Metadata
Assignees
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)Issues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancementA general enhancement