Anchor VersionMapper to the trailing version segment (#374) - #380
Open
elharo wants to merge 1 commit into
Open
Conversation
slachiewicz
removed their request for review
August 10, 2026 20:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #374
Summary
VersionMapper.mapFileNamehad two bugs:substring(0, index - 1)threw aStringIndexOutOfBoundsException(e.g.setFrom("1.0"),mapFileName("1.0.jar")).indexOfmatched the first occurrence of the version string, so a version appearing inside the artifactId was stripped instead of the trailing version segment (e.g.a-1.0-b-1.0.jarmapped toa-b-1.0.jarinstead ofa-1.0-b.jar). A version-like substring not at a segment boundary was also stripped (e.g.a-1.0b.jar→ab.jar).The mapper now anchors the match to a trailing
-<version>segment: it searches for-<version>from the end of the filename and only strips when the version is followed by the file extension (.), a-<classifier>segment, or nothing. Because the match always includes the leading-, the index-0 crash is impossible and the version is no longer stripped from the middle of the artifact id.Changes
VersionMapper.java: replace the unanchoredindexOf+substring(0, index - 1)with alastIndexOf('-' + version)loop that validates the trailing segment boundary.VersionMapperTestcovering the basic case, classifier handling, the index-0 crash, the wrong-occurrence stripping, the non-boundary substring, directory preservation, and the no-match case.Verification
mvn verify(rat, checkstyle, spotless, unit tests, javadoc) passes.mvn verify -Prun-itspasses: all 29 integration tests succeed.