DefaultAsyncClient never completes the returned future when Client throws Error · Issue #3629 · OpenFeign/feign · GitHub
Skip to content

DefaultAsyncClient never completes the returned future when Client throws Error #3629

Open

Description

@hutiefang76

DefaultAsyncClient can leave its returned CompletableFuture pending forever when the synchronous client throws an Error.

The adapter submits a task to an ExecutorService, then completes a separate future inside catch (Exception). An AssertionError bypasses that catch. The executor captures it in its own FutureTask, while the future returned to the caller is never completed. This also hangs a call made through AsyncFeign.

A bounded reproduction on current master e32547a uses a normal single-thread executor and a client lambda that throws one pre-created AssertionError:

Client client = (request, options) -> { throw failure; };
CompletableFuture<Response> response = new DefaultAsyncClient<Void>(client, executor)
    .execute(request, new Request.Options(), Optional.empty());
response.get(1, TimeUnit.SECONDS);

Expected: an ExecutionException whose cause is the original error, consistent with the AsyncClient completion contract. Actual: TimeoutException.

I added direct-adapter and public AsyncFeign cases to the existing AsyncFeignTest, with IOException, runtime-exception and successful-response controls. The actual run reports 59 tests, 2 failures, 0 errors/skips; both failures are the expected timeout. Each executor is shut down in finally; the cases use no network request or real VM exhaustion.

Verification used the unmodified Maven build with the dev profile, JDK 8 for main sources and JDK 25 for tests. The change can be limited to completing the returned future exceptionally for any throwable from the synchronous client; executor rejection and other async adapters are outside this report. I will send that small fix with these regressions and a changelog entry.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions