Use case: spring-cloud-contract project needs to autoconfigure RestTemaplate with "relaxed SSL validation" when used in tests against HTTPS wiremock stubs, but only for Apache HttpComponents. In order to do this, we need a way to get requestFactory and inspect if it's instance of HttpComponentsClientHttpRequestFactory.

Problem: If RestTemplate is used with interceptors, getRequestFactory() will return wrapper -> InterceptingClientHttpRequestFactory which doesn't expose any methods to revel it's implementation.

https://github.com/spring-projects/spring-framework/blob/v6.0.4/spring-web/src/main/java/org/springframework/http/client/support/InterceptingHttpAccessor.java#L102-L108

We made a work-around and used reflections to get requestFactory field form RestTemplate, but We want to avoid using reflections.

Spring cloud contract issue: spring-cloud/spring-cloud-contract#1868 Spring cloud contract pull: spring-cloud/spring-cloud-contract#1869

Comment From: snicoll

This looks like this would require quite a lot of knowledge of the internals. The factory is exposed but us creating a wrapper and changing it is fair game. The wrapper could not even be public so I don't see this as a great outcome on both end.

Can we take a step back and look at the use cases rather? If some configuration of the request factory needs to happen, can't it happen upfront?

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.