question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Async CompletableFuture append errors

See original GitHub issue

I’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:closed
  • Created 6 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
whiskeysierracommented, Nov 22, 2017

@kakawait I created #119 to enhance the readme. I’m not sure how to fix this programatically.

1reaction
whiskeysierracommented, Sep 26, 2017

We always exclude that one from our applications:

@EnableAutoConfiguration(exclude = ErrorMvcAutoConfiguration.class)

@lukasniemeier-zalando Can you remember why exactly?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found