Repository navigation
Find CompletableFuture async calls without an Executor - #1313
Merged
steve-aom-elliott merged 7 commits intoOct 20, 2026
Merged
Conversation
From JDK 25, CompletableFuture's default async executor is always ForkJoinPool.asyncCommonPool(); the thread-per-task fallback used when common-pool parallelism is <= 1 is gone. On hosts with <= 2 CPUs, blocking work submitted without an Executor now queues behind a single worker.
Before JDK 25, CompletableFuture swapped an explicit commonPool() argument for the thread-per-task fallback when common-pool parallelism was 1 or less. JDK 25 dropped that substitution, so these calls regress the same way as Executor-less calls.
timtebeek
approved these changes
Oct 20, 2026
timtebeek
left a comment
Member
There was a problem hiding this comment.
Thanks! Few small changes & added it to the larger composite, as the search result marker won't end up on committed changes (for CLI) anyway. Plugin users who see this will want to consciously choose an executor.
…re-default-executor # Conflicts: # src/main/resources/META-INF/rewrite/recipes.csv
…re-default-executor
steve-aom-elliott
deleted the
find-completable-future-default-executor
branch
October 20, 2026 21:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's changed
Adds
FindCompletableFutureDefaultExecutor, a search recipe. It marks:CompletableFuture/CompletionStage*Async(..)calls without a trailingExecutorargument (supplyAsync,runAsync,thenApplyAsync,thenComposeAsync,thenCombineAsync,whenCompleteAsync,completeAsync, …).CompletableFuture.delayedExecutor(long, TimeUnit)without a base executor.ForkJoinPool.commonPool()explicitly. Before JDK 25,CompletableFuturesubstituted an explicitcommonPool()with the thread-per-task fallback too, and JDK 25 removed that substitution.What's your motivation?
JDK 25 changed
CompletableFuture's default async executor:commonPool(), or thread-per-task if parallelism ≤ 1ForkJoinPool.asyncCommonPool(), no fallbackOn a host with ≤ 2 CPUs, common-pool parallelism is 1, and
asyncCommonPool()only adjusts it when it is 0. Blocking work (JDBC, HTTP) submitted without anExecutortherefore used to get a fresh thread per task, but on JDK 25 it queues behind a single worker. Small containers are common, so this can cause large latency regressions after an upgrade with no code change.Anything in particular you'd like reviewers to focus on?
UpgradeToJava25, because no Java upgrade composite currently includes a pure search recipe. Happy to add it there if preferred.CompletableFuturethat overridedefaultExecutor().