In my project, Okhttp exists in the classpath. Therefore, when initializing RestTemplate, OkHttp is selected from ClientHttpRequestFactories. However, starting from Spring 6.1, this client has been deprecated and does not work.
So I have to declare the requestFactory like code below.
return RestTemplateBuilder()
.requestFactory { _ -> SimpleClientHttpRequestFactory() }
But since Spring 6.2, OkHttpClient will be removed. Therefore, there is no need to declare a requestFactory as the default client is chosen automatically.
So, it would be nice if there was no need to declare requestFactory even in spring 6.1.x version.
Comment From: wilkinsona
starting from Spring 6.1, this client has been deprecated and does not work.
Even though it's deprecated OkHttp should continue to work as it did before. If that's not the case it should be treated as a bug.
The deprecation period is intended to give people who are using OkHttp time to migrate to another client library. If we make the changes proposed here, it will break anyone who has not yet completed that migration, making the deprecation pointless.
Spring Boot's support for OkHttp will be removed in Spring Boot 3.4 alongside our upgrade to Spring Framework 6.2.