Description
Both WebClient
and RestClient
have a unique hook point to configure the ClientHttpConnector
and ClientHttpRequestFactory
respectively. There are several convenient features that are inconsistent due to the lack of an abstraction.
MockRestServiceServer
is using a mock-based ClientHttpRequestFactory
so as soon as you try to configure one in your code, tests no longer bind to the mock server. This is as innocent as the following code (using Spring Boot helper classes):
public class AvailabilityCheckClient {
private final RestClient client;
public AvailabilityCheckClient(RestClient.Builder builder, Duration readTimeout) {
this.client = builder
.requestFactory(ClientHttpRequestFactories
.get(ClientHttpRequestFactorySettings.DEFAULTS.withReadTimeout(readTimeout)))
.build();
}
// ...
}
Spring Boot has improved SSL support which is also working via this mechanism. Same situation where everything works as expected up to a point where you need to tune anything on the request factory. See spring-projects/spring-boot#36263.
Courtesy of @wilkinsona, more related issues that provide more context when triaging this.