-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Fix CompletableFuture exception handling #22476
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
CompletableFuture exceptions are always wrapped into CompletionException. We need to unwrap CompletionException to properly handle exceptions in MVC handlers that return CompletableFuture. See https://stackoverflow.com/questions/49676889/spring-controller-advice-does-not-correctly-handle-a-completablefuture-completed
@sviperll Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@sviperll Thank you for signing the Contributor License Agreement! |
Can we get this merged? FWIW, it looks good to me. |
I've resolved this in a separate commit also adding a check to ensure the cause is not null. Thanks for submitting a PR and for pointing this out! |
Is this fix already part of a release? |
Yes, Spring Framework 5.1.7 |
@bclozel weird, I am using Spring Boot v2.1.9.RELEASE but still have this error (dependency of spring is 5.1.10) |
I have the same problem, when returning e.g. |
@maverick1601, |
Never mind, I figured, that it works as expected, just not via the |
CompletableFuture exceptions are always wrapped into CompletionException.
We need to unwrap CompletionException to properly handle exceptions in MVC handlers that return CompletableFuture.
See https://stackoverflow.com/questions/49676889/spring-controller-advice-does-not-correctly-handle-a-completablefuture-completed
#22475