Skip to content

Improve httpclient connect timeout migration - #1112

Open
Ouweshs28 wants to merge 13 commits into
openrewrite:mainfrom
Ouweshs28:improve-httpclient-connect-timeout-migration
Open

Improve httpclient connect timeout migration#1112
Ouweshs28 wants to merge 13 commits into
openrewrite:mainfrom
Ouweshs28:improve-httpclient-connect-timeout-migration

Conversation

@Ouweshs28

@Ouweshs28 Ouweshs28 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

What's changed?

  • Migrates safe setConnectTimeout(int) configurations to Apache HttpClient ConnectionConfig.
  • Retains TODO guidance for ambiguous configurations.
  • Updates recipe catalog metadata and adds positive/negative tests.

What's your motivation?

Spring Framework 7 removes HttpComponentsClientHttpRequestFactory#setConnectTimeout. This provides a safe automated migration where the pooling manager is wired to the request factory.

Anything in particular you'd like reviewers to focus on?

The safety guard proving the local manager → HttpClient → request factory flow.

Have you considered any alternatives or workarounds?

A TODO-only migration was retained for cases where the connection-manager configuration cannot be safely inferred.

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've read and applied the recipe conventions and best practices
  • I've used the IntelliJ IDEA auto-formatter on affected files

@Ouweshs28
Ouweshs28 force-pushed the improve-httpclient-connect-timeout-migration branch from 8e96c02 to c877928 Compare July 31, 2026 08:07
@timtebeek
timtebeek self-requested a review July 31, 2026 08:21
@Ouweshs28
Ouweshs28 marked this pull request as draft July 31, 2026 09:36
@Ouweshs28
Ouweshs28 force-pushed the improve-httpclient-connect-timeout-migration branch from edbf0f8 to 87a938c Compare July 31, 2026 09:45
@Ouweshs28
Ouweshs28 marked this pull request as ready for review July 31, 2026 10:42
@Ouweshs28

Copy link
Copy Markdown
Contributor Author

@timtebeek ready
its my first proper rewrite
let me know if you have any improvements

Ouwesh Seeroo and others added 3 commits August 3, 2026 15:20
The httpclient5 bump to 5.5 was committed without regenerating
classpath.tsv.gz, which still held 5.1.4; ConnectionConfig and
setDefaultConnectionConfig only exist from 5.2. That missing type
information is what required the TypeValidation opt-out and the
fully qualified ConnectionConfig in the template.

- Regenerate the type table (httpclient5 5.5.2, httpcore5 5.3.6)
- Type the template receiver and import ConnectionConfig, so the
  tests pass under full type validation
- Key migrations by the connection manager declaration, dropping the
  UUID map, the findTimeout rescan and the nested removal visitor
- Match setConnectionManager and setDefaultConnectionConfig with
  MethodMatchers rather than simple names
- Hoist the template and parser classpath out of the loop
- Run the migration before AddCommentToMethodInvocations
- Give the recipe a display name distinct from the composite
- Share one parser across tests, pinning the ambiguous spring-web-6
@Ouweshs28 Ouweshs28 closed this Aug 7, 2026
@Ouweshs28
Ouweshs28 deleted the improve-httpclient-connect-timeout-migration branch August 7, 2026 09:31
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Aug 7, 2026
@Ouweshs28
Ouweshs28 restored the improve-httpclient-connect-timeout-migration branch August 7, 2026 09:31
@timtebeek

Copy link
Copy Markdown
Member

Thanks @Ouweshs28 ; I'm behind on reviews, but what prompted you to close this one?

@Ouweshs28

Copy link
Copy Markdown
Contributor Author

i was planning out my branches i think i deleted this one by mistake hahaahaha

@Ouweshs28 Ouweshs28 reopened this Aug 7, 2026
@github-project-automation github-project-automation Bot moved this from Done to In Progress in OpenRewrite Aug 7, 2026
@Ouweshs28

Copy link
Copy Markdown
Contributor Author

@timtebeek ready for review

…nnect-timeout-migration

# Conflicts:
#	src/main/resources/META-INF/rewrite/recipes.csv
…ectTimeout

- Iterate all variables in a declaration so the second (or later) manager
  in a multi-variable declaration is recognized as the wired one
- Recognize `new HttpComponentsClientHttpRequestFactory(HttpClients.custom()
  .setConnectionManager(cm).build())` inline construction via the same
  connectionManagerName walk used for client initializers
- When a factory has multiple setConnectTimeout calls, migrate the last
  (matches Java last-write-wins) and drop earlier calls only when no
  intervening statement references the factory, client, or manager
- Split the overloaded wiredTo map into clientToManager and factoryToManager
- Key migrations by manager name so two managers in one declaration do not
  collide, and target the specific variable in the inserted template

Adds four tests covering each new shape.
@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Aug 14, 2026
@Ouweshs28

Copy link
Copy Markdown
Contributor Author

thanks @steve-aom-elliott

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

Labels

None yet

Projects

Status: Ready to Review

Development

Successfully merging this pull request may close these issues.

3 participants