Skip to content

Conversation

@Nhahan
Copy link
Contributor

@Nhahan Nhahan commented Nov 24, 2025

Fixes gh-48273

Summary

REST_CLIENT-based HTTP Service clients do not apply spring.http.serviceclient.* properties in WebFlux applications, even when spring.threads.virtual.enabled=true, because the current condition strictly excludes all reactive applications.

Changes

  • Update HttpServiceClientAutoConfiguration to use a condition that permits reactive applications when virtual threads and applicationTaskExecutor are enabled.
  • Add matching package-private condition NotReactiveWebApplicationOrVirtualThreadsExecutorEnabledCondition in the service package (kept in sync with the existing one in autoconfigure package).
  • Add regression test: restClientServiceClientsApplyPropertiesWhenReactiveWithVirtualThreads().

Testing

  • Verified with ./gradlew :module:spring-boot-restclient:check
  • Verified with ./gradlew :module:spring-boot-restclient:checkFormatMain
  • New test confirms that auto-configuration activates and applies properties (e.g., base URL) when virtual threads are enabled in a reactive environment.

Previously, HttpServiceClientAutoConfiguration used
NotReactiveWebApplicationCondition, which prevented
activation in reactive apps even when virtual threads
were enabled.

This commit updates the condition to
NotReactiveWebApplicationOrVirtualThreadsExecutorEnabledCondition,
allowing HTTP Service Clients to work in reactive apps
when virtual threads are enabled, matching the behavior
of RestClientAutoConfiguration.

Closes spring-projectsgh-48273

Signed-off-by: Nhahan <kisy324@naver.com>
@wilkinsona wilkinsona changed the title Allow RestClient HTTP service auto-config in reactive apps when virtual threads are enabled Enabling virtual threads in a reactive web application does not enable auto-configuration of RestClient-based HTTP service clients Nov 25, 2025
@wilkinsona
Copy link
Member

See #44952 where we relaxed things in 3.5 for RestClient. It would seem reasonable for things to work similarly for HTTP service clients that are built on top of RestClient.

@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 25, 2025
@wilkinsona wilkinsona added this to the 4.0.x milestone Nov 25, 2025
@snicoll snicoll self-assigned this Nov 26, 2025
snicoll pushed a commit that referenced this pull request Nov 27, 2025
Previously, HttpServiceClientAutoConfiguration used
NotReactiveWebApplicationCondition, which prevented
activation in reactive apps even when virtual threads
were enabled.

This commit removes the condition to follow suite with what was done in
gh-48308

See gh-48274

Signed-off-by: Nhahan <kisy324@naver.com>
@snicoll snicoll closed this in a5a0ad2 Nov 27, 2025
@snicoll snicoll modified the milestones: 4.0.x, 4.0.1 Nov 27, 2025
@snicoll snicoll changed the title Enabling virtual threads in a reactive web application does not enable auto-configuration of RestClient-based HTTP service clients Relax conditions to configure RestClient-based HTTP service clients Nov 27, 2025
@snicoll snicoll changed the title Relax conditions to configure RestClient-based HTTP service clients Conditions to auto-configure RestClient-based HTTP service clients are outdated with the modularization Nov 27, 2025
@snicoll
Copy link
Member

snicoll commented Nov 27, 2025

@Nhahan thanks for the PR. Looking at the duplication of the condition this made us brainstorm if it was needed at all following the modularization. We concluded that it wasn't now that the module has to be added explicitly on the classpath. I've therefore polished by removing the condition altogether. We did the same for the base RestClient auto-config in #48308.

@Nhahan

This comment was marked as resolved.

@snicoll

This comment was marked as resolved.

@Nhahan

This comment was marked as resolved.

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

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RestClient HTTP service clients ignore properties in reactive + virtual threads

4 participants