Completes async client futures when the delegate throws Error by hutiefang76 · Pull Request #3630 · OpenFeign/feign · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
6 changes: 4 additions & 2 deletions core/src/main/java/feign/DefaultAsyncClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ public CompletableFuture<Response> execute(
() -> {
try {
result.complete(client.execute(request, options));
} catch (final Exception e) {
result.completeExceptionally(e);
} catch (final Throwable throwable) {
// Throwable, not Exception: the future is the only completion channel, so an
// Error escaping the client must fail it rather than leave it pending.
result.completeExceptionally(throwable);
}
});
result.whenComplete(
Expand Down
141 changes: 141 additions & 0 deletions core/src/test/java/feign/AsyncFeignTest.java