Skip to content

RestTemplateBuilder with readtimeout and httpclient5 fails with IllegalStateException #29404

Closed as not planned
@soft4rchitecture

Description

@soft4rchitecture

Affects: org.springframework.boot:spring-boot:3.0.0-RC1


What are we trying to do ?

instantiate a RestTemplateBuilder while having org.apache.httpcomponents.client5:httpclient5 on the runtime classpath.
(probable explanation in the end)

reproduce

https://gist.github.com/soft4rchitecture/729cf677a49d6d07a852aa22e1c9f830

expected result

the test succeeds

current result

the test fails with the following stack trace

preliminary explanations

org.springframework.boot.web.client.ClientHttpRequestFactorySupplier is called to supply a CLientHttpRequestFactory.
If org.apache.hc.client5.http.impl.classic.HttpClients is on the class path, then org.springframework.http.client.HttpComponentsClientHttpRequestFactory is provided.
HttpComponentsClientHttpRequestFactory actually has the setReadTimeout() method deprecated since 6.0.
When org.springframework.boot.web.client.RestTemplateBuilder.RequestFactoryCustomizer#setReadTimeout calls
org.springframework.http.client.HttpComponentsClientHttpRequestFactory#setReadTimeout then expection is thrown

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions