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.

Comment From: wilkinsona

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 https://github.com/spring-projects/spring-boot/pull/36118 and https://github.com/spring-projects/spring-boot/issues/36266 for further details.

Comment From: scottfrederick

Closing in favor of #36266.

Comment From: Washingtonwei

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