Skip to content
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

Consider harmonizing the Spring Framework and Spring Boot defaults for RestClient request factory #38856

Closed
scottfrederick opened this issue Dec 18, 2023 · 3 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@scottfrederick
Copy link
Contributor

Spring Framework documents that the default ClientHttpRequestFactory used when building a RestClient is the following, conditional on the classpath:

  • Apache HTTP Client
  • Jetty HTTP Client
  • JDK HTTP Client
  • SimpleClientHttpRequestFactory

Spring Boot's RestClient auto-configuration overrides the request factory using ClientHttpRequestFactories, which has the following order:

  • Apache HTTP Client
  • Jetty HTTP Client
  • OkHttp3 Client (deprecated)
  • SimpleClientHttpRequestFactory

The result is that the JDK HTTP client is not considered when Spring Boot auto-configures the RestClient. We should consider bringing the Boot defaults in line with Framework.

@wilkinsona
Copy link
Member

JdkClientHttpRequestFactory and SimpleClientHttpRequestFactory behave differently, particularly with respect to redirects. With no easy was to choose to use the simple client instead of the JDK client, we didn't want to make a breaking change to the default. See #36118 and #36266 for further details.

@scottfrederick
Copy link
Contributor Author

Closing in favor of #36266.

@scottfrederick scottfrederick closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2024
@scottfrederick scottfrederick added status: declined A suggestion or change that we don't feel we should currently apply 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 Jan 2, 2024
@Washingtonwei
Copy link

JdkClientHttpRequestFactory and SimpleClientHttpRequestFactory behave differently, particularly with respect to redirects. With no easy was to choose to use the simple client instead of the JDK client, we didn't want to make a breaking change to the default. See #36118 and #36266 for further details.

Thank you! I am glad that since Spring Boot 3.4.0, JdkClientHttpRequestFactory is now the default HTTP client library instead of SimpleClientHttpRequestFactory. See https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.4-Release-Notes#restclient-and-resttemplate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

3 participants