Skip to content

WebClient and RestClient should offer a way to customize ClientHttpConnector/ClientHttpRequestFactory rather than replacing it #32338

Closed as not planned
@snicoll

Description

@snicoll

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.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)status: supersededAn issue that has been superseded by anothertype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions