Description
When creating a RestTemplate
from spring-boot auto-configured RestTemplateBuilder
, by default, it auto detects ClientHttpRequestFactory
from loaded libraries by ClientHttpRequestFactorySupplier
.
This is based on RestTemplateBuilder.detectRequestFactory
is true
by default.
The back story is that this auto-detection bit us. When some of the apps changed the RestTemplate
bean definition from directly instantiating RestTemplate
to use spring-boot auto-configured RestTemplateBuilder
, this auto-detection kicked in and found http-client in the path and enabled connection-pooling. For those apps, due to unfortunate infra issue, we cannot use connection pooling for now, but the connection-pool has sneaked in by this auto-detection.
To stop this auto-detection, currently application is required to define a custom RestTemplateBuilder
or RestTemplateCustomizer
.
I would like to suggest a property to toggle this behavior, so that no bean definition is required to disable the auto detection.
For implementing aspect, let's say have a property spring.rest-template.detect-request-factory.enabled
, and based on the value, toggle RestTemplateBuilder.detectRequestFactory
in RestTemplateAutoConfiguration
.
If this sounds good, I'll create a PR.
Thanks,