Skip to content

Ensure RestClient uses Virtual Thread Executor when spring.threads.virtual.enabled=true and JdkClientHttpRequestFactoryBuilder #46404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

smartandhandsome
Copy link

@smartandhandsome smartandhandsome commented Jul 11, 2025

Previously, even when setting spring.threads.virtual.enabled=true, HttpClient in RestClient continued to create platform threads. This meant that enabling virtual threads via configuration did not actually switch the executor as users would expect.

What has changed

  • The configuration for the ClientHttpRequestFactoryBuilder bean has been split based on the threading mode.
  • When Threading.VIRTUAL is active and the builder is a JdkClientHttpRequestFactoryBuilder, the builder is explicitly configured to use a virtual thread executor.
  • For platform threads, the previous behavior is preserved.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 11, 2025
@philwebb philwebb self-assigned this Jul 21, 2025
@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label Jul 21, 2025
@philwebb
Copy link
Member

Flagging for team attention to see if we consider this a bug or enhancement. I lean towards enhancement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants