Spring boot 3.1.0 RestTemplateBuilder with apache HTTP client in classpath (org.apache.httpcomponents.client5:httpclient5) ignore java system HTTP proxy command line options like -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888.
Spring boot before 3.1 respects such settings.
For simple RestTemplate restTemplate = restTemplateBuilder.build() spring boot 2.7 instantiate HttpComponentsClientHttpRequestFactory via default constructor, which create HTTP client as HttpClients.createSystem(), i.e. with system proxy support.
Spring boot 3.0 (if readTimeout duration is not set) also create HttpComponentsClientHttpRequestFactory via default constructor and HTTP client as HttpClients.createSystem().
But spring boot 3.1 create HTTP client as HttpClientBuilder.create().setConnectionManager(connectionManager).build(). Without useSystemProperties() as HttpClients.createSystem() makes.
Suggestion: add useSystemProperties() to createHttpClient method like this
return HttpClientBuilder.create()
.useSystemProperties()
.setConnectionManager(connectionManager)
.build();
For compatibility with spring boot 2.x, 3.0, and core spring HttpComponentsClientHttpRequestFactory.
Comment From: scottfrederick
While it does appear that behavior changed with 3.1 in this regard, the fact that previous releases allowed system properties to be applied in some cases but not others (for example, when readTimeout is set) doesn't seem right to me. We might want to address this in earlier versions, and make sure that system properties can be applied in all cases.
Marking this for team attention to see what other think.
Comment From: mhalbritter
I agree with you Scott. We should restore old behavior and fix the inconsistencies in earlier versions.
Comment From: p-palanisami
I am new to Open Source Contributor. Shall i work on this issue?
Comment From: wilkinsona
Thanks for the offer, @p-palanisami, but this issue is already assigned to @scottfrederick. I'm not sure if we have any at the moment, but please keep an eye out for unassigned issues labelled with ideal for contribution or, as your haven't contributed before, first-timers only.