[ 
https://issues.apache.org/jira/browse/WW-3784?focusedWorklogId=1032268&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-1032268
 ]

ASF GitHub Bot logged work on WW-3784:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 26/Jul/26 07:06
            Start Date: 26/Jul/26 07:06
    Worklog Time Spent: 10m 
      Work Description: Copilot commented on code in PR #1813:
URL: https://github.com/apache/struts/pull/1813#discussion_r3651975999


##########
core/src/main/java/org/apache/struts2/config/entities/PackageConfig.java:
##########
@@ -517,6 +518,26 @@ public Builder addActionConfig(String name, ActionConfig 
action) {
             return this;
         }
 
+        /**
+         * Re-inserts this package's action configs into a new 
insertion-ordered map,
+         * ordered by the supplied comparator over the action-name keys. Must 
be called
+         * before {@link #build()}.
+         *
+         * @param byActionName comparator over action names determining match 
precedence
+         * @return this builder
+         * @since 7.3.0 (WW-3784)
+         */
+        public Builder reorderActionConfigs(Comparator<String> byActionName) {
+            List<Map.Entry<String, ActionConfig>> entries = new 
ArrayList<>(target.actionConfigs.entrySet());
+            entries.sort(Map.Entry.comparingByKey(byActionName));
+            Map<String, ActionConfig> reordered = new LinkedHashMap<>();

Review Comment:
   `PackageConfig.Builder.reorderActionConfigs(...)` accepts a public 
comparator but doesn’t validate it. If `byActionName` is null, this will fail 
later with a less-clear NPE from `comparingByKey`, rather than at the API 
boundary with an explicit message.





Issue Time Tracking
-------------------

    Worklog Id:     (was: 1032268)
    Time Spent: 40m  (was: 0.5h)

> Greedy and non-greedy matching behaviour should work in action methods using 
> annotated wildcards 
> -------------------------------------------------------------------------------------------------
>
>                 Key: WW-3784
>                 URL: https://issues.apache.org/jira/browse/WW-3784
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions
>    Affects Versions: 2.3.1.2
>         Environment: Win XP, Linux / JDK 7 (Oracle)
>            Reporter: Mo Be
>            Assignee: Lukasz Lenart
>            Priority: Major
>             Fix For: 7.3.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> {code:java}
> @Namespace("/do")
> public class CRUDAction {
>     /* [1] specific wildcard */
>     @Override @Action(value="some/usefull/{stuff}",results={@Result(location 
> = "result.jsp")})
>     public String execute() throws Exception {...}
>     /* [2] less specific wildcard */
>     @Override @Action(value="some/{stuff}", results={@Result(location 
> ="result.jsp")})
>     public String input() throws Exception {...} 
> }
> {code}
> Currently pattern [2] due to greedy natching catches every 
> "/do/some/\{stuff}" AND "/do/some/usefull/\{stuff}" event.
> For instance while calling /do/some/eating or /do/some/usefull/sleeping will 
> both end in [2] where stuff becomes "eating" or "usefull/sleep" respectively, 
> [1] is left behind with nothing to do.
> The expected matching behaviour should always be from more specific to less 
> specific.
> I.e. [2] should never fire before [1]. So that /do/some/usefull/sleeping 
> would correctly map to [1] with stuff==sleeping and /do/some/eating correctly 
> maps to [2] with stuff==eating.
> Using xml one can achieve the correct matching order by re-ordering the 
> action definitions (most specific action mapping comes first) 
>    



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to