Skip to content

Fix MavenDependency#findNewerVersion ExactVersion edge cases#7305

Merged
timtebeek merged 1 commit intomainfrom
tim/maven-dep-find-newer-fix
Apr 7, 2026
Merged

Fix MavenDependency#findNewerVersion ExactVersion edge cases#7305
timtebeek merged 1 commit intomainfrom
tim/maven-dep-find-newer-fix

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented Apr 7, 2026

Summary

  • Fixes MavenDependency#findNewerVersion - unnecessary downloads, edge cases #5062

  • Early exit for ExactVersion: Before downloading Maven metadata, checks whether the exact target version is actually an upgrade from the current version. If not (same version or a downgrade), returns null immediately, avoiding unnecessary HTTP traffic.

  • Fix corrupt-metadata fallback: The fallback path for incomplete Maven metadata (e.g. MapR repository) previously returned the exact version unconditionally if the POM was downloadable. Now it verifies the version is an actual upgrade, consistent with how VersionComparator.upgrade() works.

Test plan

  • ./gradlew :rewrite-maven:test --tests "*UpgradeDependencyVersion*" — all pass
  • ./gradlew :rewrite-maven:test --tests "*MavenDependency*" — all pass

Closes #5062

- Add early exit for ExactVersion before downloading metadata when the
  target version is not an upgrade from the current version, avoiding
  unnecessary HTTP traffic.
- Fix the corrupt-metadata fallback to verify the exact version is
  actually an upgrade before returning it, instead of returning it
  unconditionally.
@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Apr 7, 2026
@timtebeek timtebeek merged commit de200b2 into main Apr 7, 2026
1 check passed
@timtebeek timtebeek deleted the tim/maven-dep-find-newer-fix branch April 7, 2026 13:27
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

MavenDependency#findNewerVersion - unnecessary downloads, edge cases

2 participants