[
https://issues.apache.org/jira/browse/WW-5743?focusedWorklogId=1042228&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1042228
]
ASF GitHub Bot logged work on WW-5743:
--------------------------------------
Author: ASF GitHub Bot
Created on: 17/Sep/26 06:44
Start Date: 17/Sep/26 06:44
Worklog Time Spent: 10m
Work Description: lukaszlenart opened a new pull request, #1962:
URL: https://github.com/apache/struts/pull/1962
Fixes [WW-5743](https://issues.apache.org/jira/browse/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](https://claude.com/claude-code)
Issue Time Tracking
-------------------
Worklog Id: (was: 1042228)
Remaining Estimate: 0h
Time Spent: 10m
> ActionNameSpecificityComparator can rank a broad ** pattern ahead of a
> narrower */* one
> ---------------------------------------------------------------------------------------
>
> Key: WW-5743
> URL: https://issues.apache.org/jira/browse/WW-5743
> Project: Struts 2
> Issue Type: Improvement
> Components: Plugin - Convention
> Reporter: Lukasz Lenart
> Assignee: Lukasz Lenart
> Priority: Major
> Fix For: 7.4.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Follow-up to WW-3784 (7.3.0), which introduced
> {{ActionNameSpecificityComparator}} in the Convention plugin so annotated
> wildcard actions are matched most-specific-first instead of in class-scan
> order.
> The comparator's keys, in order, are: fewer wildcard tokens first, more
> literal characters first, fewer path-spanning {{\*\*}} tokens first, then
> lexical. Because the raw token count comes before the {{\*\*}} count, a
> pattern with one {{\*\*}} outranks a pattern with two {{\*}} even though
> {{\*\*}} crosses {{/}} and {{\*}} does not ({{WildcardHelper}} MATCH\_PATH vs
> MATCH\_FILE) — so {{\*\*}} is the broader pattern of the two and should lose:
> * {{a/\*\*}} — 1 wildcard token, 1 path-spanning
> * {{a/\*/\*}} — 2 wildcard tokens, 0 path-spanning
> Today the first sorts ahead of the second and shadows it for {{a/x/y}}.
> Proposed refinement: lift the {{**}}-count key above the raw token-count key
> (fewer {{\*\*}} first, then fewer tokens, then more literals). Ordering stays
> per-package by design. Worth a test pair in
> {{ActionNameSpecificityComparatorTest}} for exactly the {{a/\*\*}} vs
> {{a/\*/\*}} case, plus the {{\{var\}}} equivalent for
> {{NamedVariablePatternMatcher}} users.
> Fix version intentionally left unset.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)