Skip to content

Upgrade to HttpClient5 for HttpComponentsClientHttpRequestFactory in Spring 6 #300

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

Open
nmck257 opened this issue Mar 3, 2023 · 4 comments
Labels
boot-3.0 recipe Recipe requested

Comments

@nmck257
Copy link
Collaborator

nmck257 commented Mar 3, 2023

NOTE: Requires Apache HttpComponents 5.1 or higher, as of Spring 6.0.
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/client/HttpComponentsClientHttpRequestFactory.html

HttpComponents did a GAV change with 5, so projects with explicit dependencies on this library may be stuck on 4.x and fall into the compatibility trap documented above.

This recipe could possibly have an applicability test for projects using HttpComponentsClientHttpRequestFactory, to decrease risk of performing this upgrade (and introducing some other breaking change) on projects which don't imminently need it.

@timtebeek timtebeek moved this to Recipes Wanted in OpenRewrite Mar 3, 2023
@timtebeek timtebeek added recipe Recipe requested boot-3.0 labels Mar 3, 2023
@rpau rpau added this to the Support Spring Boot 3 migrations milestone May 24, 2023
@MahatmaFatalError
Copy link

https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#apache-httpclient-in-resttemplate

Support for Apache HttpClient has been removed in Spring Framework 6.0, immediately replaced by org.apache.httpcomponents.client5:httpclient5 (note: this dependency has a different groupId). If you are noticing issues with HTTP client behavior, it could be that RestTemplate is falling back to the JDK client. org.apache.httpcomponents:httpclient can be brought transitively by other dependencies, so your application might rely on this dependency without declaring it.

https://hc.apache.org/httpcomponents-client-5.2.x/migration-guide/preparation.html
https://hc.apache.org/httpcomponents-client-5.2.x/migration-guide/migration-to-classic.html

Just for the records ;)

@MahatmaFatalError
Copy link

FWIW https://chat.openai.com/share/3b804a18-c795-41e6-8254-335e340e9347 I asked chatGPT to do the job ;)

@rpau rpau moved this from Recipes Wanted to Up Next in OpenRewrite Jul 21, 2023
@joanvr joanvr moved this from Up Next to In Progress in OpenRewrite Jul 25, 2023
@joanvr joanvr moved this from In Progress to Up Next in OpenRewrite Aug 8, 2023
@joanvr joanvr removed their assignment Aug 8, 2023
@timtebeek timtebeek moved this from Up Next to Backlog in OpenRewrite Nov 30, 2023
@timtebeek timtebeek removed this from the Support Spring Boot 3 migrations milestone Nov 30, 2023
@aholland
Copy link

aholland commented Jan 20, 2024

I'm assuming this is the same issue I have just seen, which is that when I applied the recipe org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2 to upgrade to Spring Boot 3.2, my build.gradle dependency
implementation 'org.apache.httpcomponents:httpclient'
was not replaced with
implementation 'org.apache.httpcomponents.client5:httpclient5'
and I had to do it manually.

If this is not the same issue (?) I can create a separate new issue.

@timtebeek
Copy link
Contributor

As an update here: we've spin off the Apache HttpClient recipes into rewrite-apache:
https://github.com/openrewrite/rewrite-apache/tree/main/src/main/java/org/openrewrite/apache

To resolve this issue we'd need to add a dependency on rewrite-apache here and link the migration into the Spring Boot 3 migration, which should be fairly straightforward. Anyone welcome to pitch in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
boot-3.0 recipe Recipe requested
Projects
Status: Backlog
Development

No branches or pull requests

6 participants