Skip to content

WW-5743 fix(convention): rank path-spanning ** patterns after single-segment ones - #1962

Merged
lukaszlenart merged 1 commit into
mainfrom
feature/WW-5743-path-wildcard-ranking
Sep 17, 2026
Merged

lukaszlenart merged 1 commit into
mainfrom
feature/WW-5743-path-wildcard-ranking

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Fixes WW-5743

What

ActionNameSpecificityComparator (WW-3784, 7.3.0) compared the raw wildcard-token count before the ** count, so a/** (one token) sorted ahead of a/*/* (two tokens) and shadowed it for a/x/y — although ** crosses / (WildcardHelper MATCH_PATH) and * never does (MATCH_FILE). The ** count is now the first key, then the token count, then the literal count, then the lexical tie-break.

{var} compiles to ([^/]+) in NamedVariablePatternMatcher, so it is single-segment like * and the same rule covers both matchers. Two tests pin exactly the ticket pair for each: a/*/* vs a/** and a/{x}/{y} vs a/**.

Trade-off

Putting the ** key first means a pattern with no ** always outranks one with, regardless of literals — e.g. */*/*/*/* now sorts ahead of a/b/c/d/**. Specificity between the two is not a total order; the ticket's rule prefers "bounded depth beats unbounded depth" because that is the shadowing that actually occurs with catch-all ** actions, whereas the counter-example needs an all-wildcard fixed-depth pattern in the same package.

Docs

Companion struts-site PR updates the key list on core-developers/wildcard-mappings.md.

🤖 Generated with Claude Code

…segment ones

ActionNameSpecificityComparator compared the raw wildcard-token count before
the ** count, so `a/**` (one token) sorted ahead of `a/*/*` (two tokens) and
shadowed it for `a/x/y`, although `**` crosses `/` and `*` does not. The **
count is now the first key, then the token count, then the literal count.

Both `*` (WildcardHelper MATCH_FILE) and `{var}` (`([^/]+)` in
NamedVariablePatternMatcher) are single-segment, so the same rule covers
both matchers; the tests pin one pair for each.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

lukaszlenart added a commit to apache/struts-site that referenced this pull request Sep 17, 2026
)

Matches apache/struts#1962: the Convention plugin's most-specific-first
ordering now consults the path-spanning ** count before the wildcard-token
and literal counts, so `a/*/*` ranks ahead of `a/**`. Keeps a note on the
7.3.0 order for readers on that release.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@lukaszlenart
lukaszlenart merged commit cd6fbb3 into main Sep 17, 2026
13 checks passed
@lukaszlenart
lukaszlenart deleted the feature/WW-5743-path-wildcard-ranking branch September 17, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant