Skip to content

Configure HttpClient connection timeout via ConnectionConfig#3892

Open
strehle wants to merge 10 commits intodevelopfrom
migrate-httpclient-timeout
Open

Configure HttpClient connection timeout via ConnectionConfig#3892
strehle wants to merge 10 commits intodevelopfrom
migrate-httpclient-timeout

Conversation

@strehle
Copy link
Copy Markdown
Member

@strehle strehle commented May 4, 2026

HttpComponentsClientHttpRequestFactory.setConnectTimeout() was deprecated in Spring 6 and later removed in Spring 7. It is replaced with ConnectionConfig.setConnectTimeout() on PoolingHttpClientConnectionManager. The connection timeout is now configured at the connection manager level using the recommended ConnectionConfig.Builder API.

https://github.com/spring-projects/spring-framework/blob/9f431e2eac1b6d8d5ca385d0cc367bac94dd37e7/spring-web/src/main/java/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.java#L128-L133

gdgenchev and others added 2 commits April 23, 2026 11:04
Replace deprecated HttpComponentsClientHttpRequestFactory.setConnectTimeout()
with ConnectionConfig.setConnectTimeout() on PoolingHttpClientConnectionManager.
The connection timeout is now configured at the connection manager level using
the recommended ConnectionConfig.Builder API.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the outbound Apache HttpClient configuration in UaaHttpRequestUtils to apply connect/read timeouts at the connection manager level (via ConnectionConfig / SocketConfig), and adjusts unit tests accordingly.

Changes:

  • Move connect timeout configuration to PoolingHttpClientConnectionManager#setDefaultConnectionConfig(ConnectionConfig).
  • Move socket/read timeout configuration to PoolingHttpClientConnectionManager#setDefaultSocketConfig(SocketConfig).
  • Update UaaHttpRequestUtilsTest to use the new builder/request-factory signatures and add a test asserting the configured timeouts.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtils.java Sets connect/read timeouts via connection manager defaults; simplifies request factory to only set connection-request timeout.
server/src/test/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtilsTest.java Updates call sites and adds a reflection-based assertion that connection/socket timeouts are applied.

Comment thread server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtils.java Outdated
Comment thread server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtils.java Outdated
Comment thread server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtils.java Outdated
…bled semantics (#3900)

Previously, the `> 0` guards skipped timeout configuration when callers
passed 0, changing behavior from the old factory-level setters where 0
explicitly disabled timeouts. Now ConnectionConfig and SocketConfig are
always applied unconditionally, and Timeout.ofMilliseconds(0) correctly
maps to a disabled timeout.

Also rename the ambiguous `timeoutInMs` parameter to
`connectionRequestTimeoutInMs` to clarify it is the pool lease timeout.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtils.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtils.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comment thread server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtils.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

Comment thread server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtils.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants