Skip to content

Configure HttpClient connection timeout via ConnectionConfig#3864

Closed
gdgenchev wants to merge 1 commit intocloudfoundry:developfrom
gdgenchev:migrate-httpclient-timeout
Closed

Configure HttpClient connection timeout via ConnectionConfig#3864
gdgenchev wants to merge 1 commit intocloudfoundry:developfrom
gdgenchev:migrate-httpclient-timeout

Conversation

@gdgenchev
Copy link
Copy Markdown
Contributor

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

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

Updates UAA’s Apache HttpClient/Spring RestTemplate setup to configure the TCP connection timeout using Apache HttpClient’s ConnectionConfig on the PoolingHttpClientConnectionManager, aligning with Spring’s removal of HttpComponentsClientHttpRequestFactory.setConnectTimeout() in Spring 7.

Changes:

  • Remove usage of HttpComponentsClientHttpRequestFactory.setConnectTimeout(...).
  • Add connect-timeout configuration via ConnectionConfig.setConnectTimeout(Timeout) on the pooling connection manager.
  • Update the unit test to use the new getClientBuilder(..., connectTimeoutInMs) signature.

Reviewed changes

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

File Description
server/src/main/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtils.java Moves connect-timeout configuration from Spring’s request factory to Apache HttpClient connection manager ConnectionConfig.
server/src/test/java/org/cloudfoundry/identity/uaa/util/UaaHttpRequestUtilsTest.java Updates test helper to call the updated getClientBuilder API with an explicit connect timeout.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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 on lines +115 to +119
ConnectionConfig connectionConfig = ConnectionConfig.custom()
.setConnectTimeout(Timeout.ofMilliseconds(connectTimeoutInMs))
.build();
cm.setDefaultConnectionConfig(connectionConfig);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

see 389c7cd

@strehle
Copy link
Copy Markdown
Member

strehle commented May 4, 2026

@gdgenchev I have done changes from my local review to extra commit of #3892

@fhanik
Copy link
Copy Markdown
Contributor

fhanik commented May 5, 2026

#3892 appears to try to address the same thing. which one would you like approved?

@gdgenchev
Copy link
Copy Markdown
Contributor Author

Let's continue in #3892

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.

4 participants