Skip to content

Autoconfigure settings such as timeouts and redirects for RestClient and RestTemplate and WebClient #43068

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
quaff opened this issue Nov 8, 2024 · 5 comments
Labels
status: duplicate A duplicate of another issue

Comments

@quaff
Copy link
Contributor

quaff commented Nov 8, 2024

We should introduce a @ConfigurationProperties bean for [RestClient|RestTemplate|WebClient]AutoConfiguration.

@ConfigurationProperties("spring.http.client")
public class HttpClientProperties {

	private Duration connectTimeout = Duration.ofSeconds(5);

	private Duration readTimeout = Duration.ofSeconds(30);

	private Redirects redirects = Redirects.FOLLOW_WHEN_POSSIBLE;

	private Class<? extends ClientHttpRequestFactory> requestFactoryType = JdkClientHttpRequestFactory.class;

	...

}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 8, 2024
@quaff
Copy link
Contributor Author

quaff commented Nov 8, 2024

I would like to prepare an PR if the team accepts the proposal.

@wilkinsona
Copy link
Member

Apologies if I have have misunderstood the proposal, but don't we already have this?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Nov 8, 2024
@quaff
Copy link
Contributor Author

quaff commented Nov 8, 2024

My apologies, I didn't notice that.

@quaff quaff closed this as completed Nov 8, 2024
@quaff
Copy link
Contributor Author

quaff commented Nov 8, 2024

But I think we should specify sensible default timeout, “Infinity” is a very bad default timeout.

@wilkinsona
Copy link
Member

wilkinsona commented Nov 8, 2024

I don't think it is infinity, at least not in all cases as it depends on the underlying client. For example, the Apache HTTP client has default connect and read timeouts of 3 minutes. Generally speaking, we prefer to keep each client's defaults as any differences may part of the reason why someone has chosen a particular client. Redirects are an exception to this as we wanted the upgrade experience to be as smooth as possible.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2024
@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants