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

Closed
wants to merge 2 commits into from

Conversation

smartandhandsome
Copy link
Contributor

@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.

@smartandhandsome
Copy link
Contributor Author

While checking, I noticed that there is an existing related issue. I’ll attach it here so it can be referenced.

#45348

@philwebb philwebb added type: enhancement A general enhancement and removed 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 labels Jul 23, 2025
@philwebb philwebb added this to the 4.0.x milestone Jul 23, 2025
philwebb pushed a commit that referenced this pull request Aug 20, 2025
philwebb pushed a commit that referenced this pull request Aug 20, 2025
Update JDK HTTP Clients so that the use virtual threads when
`Threading.VIRTUAL` is active.

See gh-46404

Signed-off-by: Sangmin Park <[email protected]>
@philwebb philwebb closed this in dbd8ab8 Aug 20, 2025
@philwebb philwebb modified the milestones: 4.0.x, 4.0.0-M2 Aug 20, 2025
@philwebb
Copy link
Member

Thanks @smartandhandsome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants