You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is inconsistency with creating org.springframework.web.client.RestClient.
When using org.springframework.web.client.RestClient#builder() method there is possibility that org.springframework.http.client.JdkClientHttpRequestFactory will be used if it's present. Code fragment from org.springframework.web.client.DefaultRestClientBuilder#build method:
So the priority of request factory looks following: HttpComponentsClientHttpRequestFactory > JettyClientHttpRequestFactory > JdkClientHttpRequestFactory > SimpleClientHttpRequestFactory.
On the other side using builder from org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration looks different. Code snippet from org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration#restClientBuilder
and org.springframework.boot.web.client.ClientHttpRequestFactories#get(org.springframework.boot.web.client.ClientHttpRequestFactorySettings)
publicstaticClientHttpRequestFactoryget(ClientHttpRequestFactorySettingssettings) {
Assert.notNull(settings, "Settings must not be null");
if (APACHE_HTTP_CLIENT_PRESENT) {
returnClientHttpRequestFactories.HttpComponents.get(settings);
} elseif (JETTY_CLIENT_PRESENT) {
returnClientHttpRequestFactories.Jetty.get(settings);
} else {
return (ClientHttpRequestFactory)(OKHTTP_CLIENT_PRESENT ? ClientHttpRequestFactories.OkHttp.get(settings) : ClientHttpRequestFactories.Simple.get(settings));
}
}
In this case priority of request factory is different: HttpComponentsClientHttpRequestFactory > JettyClientHttpRequestFactory > OkHttp3ClientHttpRequestFactory > SimpleClientHttpRequestFactory.
I think it's confusing. In first example there is attempt to use JdkClientHttpRequestFactory, in second there is not. On the other side there is attempt to use OkHttp3ClientHttpRequestFactory in second example, while in first not. Are there any reasons why there are differences in choosing request factory implementation? If not, my proposition is to make it consistent for both cases.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
Used Spring Boot version:
3.3.2
There is inconsistency with creating
org.springframework.web.client.RestClient
.When using
org.springframework.web.client.RestClient#builder()
method there is possibility thatorg.springframework.http.client.JdkClientHttpRequestFactory
will be used if it's present. Code fragment fromorg.springframework.web.client.DefaultRestClientBuilder#build
method:So the priority of request factory looks following:
HttpComponentsClientHttpRequestFactory
>JettyClientHttpRequestFactory
>JdkClientHttpRequestFactory
>SimpleClientHttpRequestFactory
.On the other side using builder from
org.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration
looks different. Code snippet fromorg.springframework.boot.autoconfigure.web.client.RestClientAutoConfiguration#restClientBuilder
and
org.springframework.boot.web.client.ClientHttpRequestFactories#get(org.springframework.boot.web.client.ClientHttpRequestFactorySettings)
In this case priority of request factory is different:
HttpComponentsClientHttpRequestFactory
>JettyClientHttpRequestFactory
>OkHttp3ClientHttpRequestFactory
>SimpleClientHttpRequestFactory
.I think it's confusing. In first example there is attempt to use
JdkClientHttpRequestFactory
, in second there is not. On the other side there is attempt to useOkHttp3ClientHttpRequestFactory
in second example, while in first not. Are there any reasons why there are differences in choosing request factory implementation? If not, my proposition is to make it consistent for both cases.The text was updated successfully, but these errors were encountered: