-
Notifications
You must be signed in to change notification settings - Fork 1.1k
INT-3724: Gateway - Support CompletableFuture #1463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
JIRA: https://jira.spring.io/browse/INT-3724 Add support for `CompletableFuture<?>` return types on gateway methods, if JDK8 is being used. - If the return type is exactly `CompletableFuture` and an async executor is provided, use `CompletableFuture.supplyAsync()` - If there is no return async executor, return types can be `CompletableFuture` or a subclass and the flow can return such a future. - Also fixes a problem for return type `Future<Message<?>>` with no async executor; previously this caused a `ClassCastException` because the gateway returned the message - it assumed such return types would always run on an excutor. We can consider back-porting this last part, but nobody has complained.
@@ -72,6 +82,13 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B | |||
} | |||
|
|||
public BeanDefinitionHolder parse(Map<String, Object> gatewayAttributes) { | |||
boolean completableFutureCapable = true; | |||
try { | |||
ClassUtils.forName("java.util.concurrent.CompletableFuture", this.beanClassLoader); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this one is a part of JVM I don't see reason to worry about classloader.
Although you have already done that we can live with that and merge as is.
Pushed docs |
If `DEBUG` logging is enabled, a log is emitted indicating that the async executor cannot be used for this scenario. | ||
|
||
|
||
`CompletionFuture` s can be used to perform additional manipulation on the reply, such as: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional word?
" CompletableFuture
s " ?
Let me know and I fix it and merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo - thanks
Merged as 5e9624f |
JIRA: https://jira.spring.io/browse/INT-3724
Add support for
CompletableFuture<?>
return types on gateway methods, if JDK8 is being used.CompletableFuture
and an async executor is provided, useCompletableFuture.supplyAsync()
CompletableFuture
or a subclass and the flow can return such a future.Future<Message<?>>
with no async executor; previously this caused aClassCastException
because the gateway returned the message - it assumed such return types would always run on an excutor.
We can consider back-porting this last part, but nobody has complained.
TODO: Docs, after review