WW-5743 fix(convention): rank path-spanning ** patterns after single-segment ones - #1962
Merged
Merged
Conversation
…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>
lukaszlenart
marked this pull request as ready for review
September 17, 2026 06:48
|
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>
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 WW-5743
What
ActionNameSpecificityComparator(WW-3784, 7.3.0) compared the raw wildcard-token count before the**count, soa/**(one token) sorted ahead ofa/*/*(two tokens) and shadowed it fora/x/y— although**crosses/(WildcardHelperMATCH_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([^/]+)inNamedVariablePatternMatcher, so it is single-segment like*and the same rule covers both matchers. Two tests pin exactly the ticket pair for each:a/*/*vsa/**anda/{x}/{y}vsa/**.Trade-off
Putting the
**key first means a pattern with no**always outranks one with, regardless of literals — e.g.*/*/*/*/*now sorts ahead ofa/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-sitePR updates the key list oncore-developers/wildcard-mappings.md.🤖 Generated with Claude Code