Skip to content

defaultRequestConfigCustomizer on HttpComponentsClientHttpRequestFactoryBuilder seems inconsistent #43427

@ThanksForAllTheFish

Description

@ThanksForAllTheFish

Hello,

I have an inquiry regarding https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/http/client/HttpComponentsClientHttpRequestFactoryBuilder.java#L181

The method is defined as

        /**
	 * Return a new {@link HttpComponentsClientHttpRequestFactoryBuilder} that applies
	 * additional customization to the underlying
	 * {@link org.apache.hc.client5.http.config.RequestConfig.Builder} used for default
	 * requests.
	 * @param defaultRequestConfigCustomizer the customizer to apply
	 * @return a new {@link HttpComponentsClientHttpRequestFactoryBuilder} instance
	 */
	public HttpComponentsClientHttpRequestFactoryBuilder withDefaultRequestConfigCustomizer(
			Consumer<RequestConfig.Builder> defaultRequestConfigCustomizer) {
		Assert.notNull(defaultRequestConfigCustomizer, "'defaultRequestConfigCustomizer' must not be null");
		return new HttpComponentsClientHttpRequestFactoryBuilder(getCustomizers(), this.httpClientCustomizer,
				this.connectionManagerCustomizer, this.socketConfigCustomizer, defaultRequestConfigCustomizer,
				this.tlsSocketStrategyFactory);
	}

according to the javadoc, the input request config builder customizer should apply addition customization, but the implementation actually replaces the previous behavior.

Is there a reason to not have this.defaultRequestConfigCustomizer.andThen(defaultRequestConfigCustomizer) instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: supersededAn issue that has been superseded by another

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions