You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#119 made executeAsync route a requestAdapter.adapt(...) failure through the returned CompletableFuture instead of throwing on the caller's thread. The guard wraps the adapt(...) call only; the dispatch kickoff that runs immediately after — still on the caller's thread, before the future is handed back — is not covered.
OkHttp is already safe here: client.newCall(...) does no throwing work, and a RejectedExecutionException from a shut-down dispatcher is delivered through Callback.onFailure → the future. No change needed.
JDK calls client.sendAsync(...) outside the guard. sendAsync does not guarantee that every failure arrives through the returned future — e.g. invoking it on a closed java.net.http.HttpClient (JDK 21+, where the client is AutoCloseable) throws synchronously. Such a throw would escape on the caller's thread — the same inconsistency executeAsync throws request-adaptation failures synchronously instead of via the returned future #118 set out to remove.
This needs a closed/misconfigured client rather than a normal request, so it is low-probability and filed separately from #118 rather than folded into #119.
Proposed change
Extend the JDK executeAsync try/catch to also enclose client.sendAsync(...) (and the bridgeAsyncResponse(...) wiring), so any synchronous throw from dispatch is returned as a failed future, matching the async error-delivery contract. Leave OkHttp as-is, optionally with a short comment noting why its post-adapt path is already future-safe.
Acceptance
A synchronous throw from the JDK dispatch path surfaces through the returned future, not on the caller's thread.
The executeAsync KDoc's error-delivery contract holds for the whole method body, not just adaptation.
Follow-up from #119.
#119 made
executeAsyncroute arequestAdapter.adapt(...)failure through the returnedCompletableFutureinstead of throwing on the caller's thread. The guard wraps theadapt(...)call only; the dispatch kickoff that runs immediately after — still on the caller's thread, before the future is handed back — is not covered.client.newCall(...)does no throwing work, and aRejectedExecutionExceptionfrom a shut-down dispatcher is delivered throughCallback.onFailure→ the future. No change needed.client.sendAsync(...)outside the guard.sendAsyncdoes not guarantee that every failure arrives through the returned future — e.g. invoking it on a closedjava.net.http.HttpClient(JDK 21+, where the client isAutoCloseable) throws synchronously. Such a throw would escape on the caller's thread — the same inconsistency executeAsync throws request-adaptation failures synchronously instead of via the returned future #118 set out to remove.This needs a closed/misconfigured client rather than a normal request, so it is low-probability and filed separately from #118 rather than folded into #119.
Proposed change
Extend the JDK
executeAsynctry/catch to also encloseclient.sendAsync(...)(and thebridgeAsyncResponse(...)wiring), so any synchronous throw from dispatch is returned as a failed future, matching the async error-delivery contract. Leave OkHttp as-is, optionally with a short comment noting why its post-adapt path is already future-safe.Acceptance
executeAsyncKDoc's error-delivery contract holds for the whole method body, not just adaptation.