Async CompletableFuture append errors
See original GitHub issueI’m not totally sure error comes from problem spring web but if I have a controller with following code:
@PutMapping(value = "/{name}")
public CompletableFuture<User> updateLaboratoryByName(@RequestBody User user) {
return service.save(laboratory).thenApply(this::toLaboratoryResponse);
}
With basic service
@Async
@Transactional
public CompletableFuture<user> save(User user) {
if (<SOME CONDITION, WHATEVER>) {
thrown new IllegalArgumentException("blabla");
}
return CompletableFuture.completedFuture(repository.save(laboratory));
}
Both messages will be display on response
{
"title": "Internal Server Error",
"status": 500,
"detail": "java.lang.IllegalArgumentException: blabla"
}{
"timestamp": "2017-09-25T12:16:50.615+0000",
"status": 500,
"error": "Internal Server Error",
"exception": "java.util.concurrent.CompletionException",
"message": "java.lang.IllegalArgumentException: blabla",
"path": "/api/v1/users/XXXXX"
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (9 by maintainers)
Top Results From Across the Web
CompletableFuture in loop: How to collect all responses and ...
First thing, don't use thenApply(responses::add) on a non-thread-safe collection like ArrayList , as it will likely break the collection ...
Read more >Java CompletableFuture Tutorial with Examples - CalliCoder
In this tutorial you'll learn What CompletableFuture is and how to use CompletableFuture for asynchronous programming in Java.
Read more >Handling Errors in CompletableFuture java 8 - YouTube
In this video tutorial we will learn how to handle exception in CompletableFuture in java 8 using a demo project.Below is the GitHub...
Read more >Write Clean Asynchronous Code With CompletableFuture ...
CompletableFuture allows us to write non-blocking code by running a task on a separate thread than the main application thread and notifying ...
Read more >Fantastic CompletableFuture.allOf() and how to handle errors.
I looked into new java8 CompletableFuture class looking for a way to collect all the asynchronous tasks which I submit and wait for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kakawait I created #119 to enhance the readme. I’m not sure how to fix this programatically.
We always exclude that one from our applications:
@lukasniemeier-zalando Can you remember why exactly?