Skip to content

Improve httpclient 4->5 AuthScheme-related migration #85

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

Merged
merged 3 commits into from
Jul 7, 2025
Merged

Conversation

pdelagrave
Copy link
Contributor

@pdelagrave pdelagrave commented Jun 30, 2025

What's changed?

The main UpgradeApacheHttpClient_5 declarative recipe now:

  • Refactors the BasicSchemeFactory() and DigestSchemeFactory() constructors usage to remove the deprecated argument use.
  • Rename classes AuthSchemeProvider and AuthSchemes with their new names.
  • Rename method AuthScheme.getSchemeName() to AuthScheme.getName()

What's your motivation?

Fix a reported issue with missing auth migrations in http client.

Any additional context

The Apache HttpClient release notes and migration guide are missing many renamed classes, methods, etc. Hence adding more support as required.

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

@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jun 30, 2025
@pdelagrave pdelagrave force-pushed the authschemes branch 3 times, most recently from 7a97bb4 to eed273e Compare June 30, 2025 21:13
@pdelagrave
Copy link
Contributor Author

I've converted it all to declarative as we can simply use org.openrewrite.java.DeleteMethodArgument.

@timtebeek timtebeek self-requested a review July 3, 2025 13:34
@pdelagrave pdelagrave changed the title Improve httpclient 4->5 auth-related migration coverage Improve httpclient 4->5 AuthScheme-related migration Jul 3, 2025
…f `DeleteMethodArgument` now does the maybeRemoveImport.
@@ -61,6 +61,13 @@ recipeList:
- org.openrewrite.apache.httpclient5.UpgradeApacheHttpClient_5_TimeUnit
- org.openrewrite.apache.httpclient5.StatusLine
- org.openrewrite.apache.httpclient5.MigrateAuthScope
- org.openrewrite.java.DeleteMethodArgument:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the first draft of that change was in its own recipe we had to include a description.

description: RFC 7616 mandates the use of UTF-8. This constructor is now deprecated and httpclient v5 ignores any provided charset, ensuring that only UTF-8 is used.

The recipeList: items doesn't support being documented with a description. Has it ever been considered?

It could be useful for example in this case where the recipe called is very generic, and the recipe name + arguments don't provide enough context to explain why we're doing that transformation.

@timtebeek timtebeek removed the status in OpenRewrite Jul 7, 2025
@timtebeek timtebeek moved this to Ready to Review in OpenRewrite Jul 7, 2025
Copy link
Member

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

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

Great to see how simple this has become with the changes upstream; thanks for the (re)work!

@timtebeek timtebeek merged commit 4c6da1d into main Jul 7, 2025
2 checks passed
@timtebeek timtebeek deleted the authschemes branch July 7, 2025 21:39
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants