Skip to content

Gracefully handle malformed Maven version strings#7234

Merged
timtebeek merged 2 commits intomainfrom
tim/fix-malformed-maven-ver
Apr 1, 2026
Merged

Gracefully handle malformed Maven version strings#7234
timtebeek merged 2 commits intomainfrom
tim/fix-malformed-maven-ver

Conversation

@timtebeek
Copy link
Copy Markdown
Member

@timtebeek timtebeek commented Apr 1, 2026

Summary

Two fixes applied: (1) the Version tokenizer's empty-token fallback now treats the token as a string qualifier instead of a number, preventing the crash at the source; (2) VersionRequirement.cacheResolved() catches IllegalArgumentException from new Version() and skips malformed versions, as a safety net for any other unforeseen parsing edge cases.

Test plan

  • VersionTest: new Version("-captain-daily-SNAPSHOT") and new Version("-") no longer throw
  • VersionRequirementTest: version range resolution succeeds when available versions include malformed strings

Fix NumberFormatException when encountering malformed version strings
like `-captain-daily-SNAPSHOT` in Maven repository metadata.

Fixes #7233
@github-project-automation github-project-automation bot moved this from In Progress to Ready to Review in OpenRewrite Apr 1, 2026
@timtebeek timtebeek merged commit 54e3e24 into main Apr 1, 2026
1 check passed
@timtebeek timtebeek deleted the tim/fix-malformed-maven-ver branch April 1, 2026 15:30
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Gracefully handle malformed Maven version strings instead of throwing exception

2 participants