Skip to content

Fix SCM path normalization edge cases in ModelInheritanceAssembler (#274) - #287

Open
elharo wants to merge 3 commits into
masterfrom
fix/issue-274-scm-path-normalization
Open

Fix SCM path normalization edge cases in ModelInheritanceAssembler (#274)#287
elharo wants to merge 3 commits into
masterfrom
fix/issue-274-scm-path-normalization

Conversation

@elharo

@elharo elharo commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Fixes #274

Problem

ModelInheritanceAssembler.appendPath/resolvePath (used for inherited SCM
connection/url values in supplemental models) had edge-case inaccuracies:

  • trailing slashes were dropped, so http://host/repo/ normalized to
    http://host/repo
  • excess .. segments were silently swallowed (an acknowledged FIXME, no
    warning)
  • empty segments (//) were removed and . segments were kept, inconsistently

Fix

Rewrote resolvePath using the JDK java.nio.file.Path.normalize() (no plexus
dependency for the new code):

  • trailing separators are now preserved
  • redundant separators, . and resolvable .. segments are collapsed
  • excess .. segments are detected instead of being silently dropped

Test

New unit test class ModelInheritanceAssemblerTest (5 tests):

  • trailing slash is preserved (fails before the fix)
  • . segments are collapsed (fails before the fix)
  • a warning is emitted for excess .. segments (fails before the fix)
  • child appending and resolvable .. normalization still work (regression)

All existing tests pass: mvn verify -Prun-its (15 unit + 9 failsafe ITs,
incl. ITSupplementalArtifact which exercises supplemental-model merging),
plus spotless/checkstyle/RAT.

@elharo
elharo marked this pull request as draft August 2, 2026 18:18
@elharo
elharo marked this pull request as ready for review August 2, 2026 18:35
public class ModelInheritanceAssembler {
private Log log;

public void setLog(Log log) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It isn't worth introducing a publc setLog method for this. Just don't log if this is required to log.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the public setLog method and the excess-'..' warning entirely; resolvePath now just normalizes (the normalizer keeps excess '..' segments instead of silently dropping them, without logging).

@elharo elharo added the bug Something isn't working label Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

appendPath/resolvePath drop trailing slashes and swallow excess '..' segments

1 participant