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

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

                Author: ASF GitHub Bot
            Created on: 21/Nov/20 13:54
            Start Date: 21/Nov/20 13:54
    Worklog Time Spent: 10m 
      Work Description: yasserzamani commented on pull request #450:
URL: https://github.com/apache/struts/pull/450#issuecomment-731582791


   Thanks! I found it :) Test has been changed through [WW-4572 Http 
parameters](https://github.com/apache/struts/pull/58) and I was watching 
original test. So basically yes then it's a breaking change, because the 
modified test doesn't try anymore that the value is always a `string[]` (The 
original test was doing via `((String[])params.get("foo"))[0]` which implicitly 
tests conversion to `string[]`).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 515056)
    Time Spent: 50m  (was: 40m)

> action tag accepts only String arrays as parameters
> ---------------------------------------------------
>
>                 Key: WW-3730
>                 URL: https://issues.apache.org/jira/browse/WW-3730
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - Tags
>    Affects Versions: 2.2.3.1, 2.3.1, 2.3.1.1, 2.3.20
>            Reporter: Pavel Kazlou
>            Priority: Major
>             Fix For: 2.6
>
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
> {{org.apache.struts2.components.Component}} accepts arbitrary objects as 
> parameters: 
> {code}
>     public Map getParameters() {
>         return parameters;
>     }
>     ...
>     public void addParameter(String key, Object value) {
>         if (key != null) {
>             Map params = getParameters();
>             if (value == null) {
>                 params.remove(key);
>             } else {
>                 params.put(key, value);
>             }
>         }
>     }
> {code}
> But {{org.apache.struts2.components.ActionComponent}} explicitly casts all 
> his parameters to {{String[]}}:
> {code}
> protected Map<String,String[]> createParametersForContext() {
>         Map parentParams = null;
>         if (!ignoreContextParams) {
>             parentParams = new 
> ActionContext(getStack().getContext()).getParameters();
>         }
>         Map<String,String[]> newParams = (parentParams != null) 
>             ? new HashMap<String,String[]>(parentParams) 
>             : new HashMap<String,String[]>();
>         if (parameters != null) {
>             Map<String,String[]> params = new HashMap<String,String[]>();
>             for (Iterator i = parameters.entrySet().iterator(); i.hasNext(); 
> ) {
>                 Map.Entry entry = (Map.Entry) i.next();
>                 String key = (String) entry.getKey();
>                 Object val = entry.getValue();
>                 if (val.getClass().isArray() && String.class == 
> val.getClass().getComponentType()) {
>                     params.put(key, (String[])val);
>                 } else {
>                     params.put(key, new String[]{val.toString()});
>                 }
>             }
>             newParams.putAll(params);
>         }
>         return newParams;
>     }
> {code}
> So I can't pass arbitrary objects directly to action using syntax:
> {code}
> <s:action name="myAction"><s:param name="customObject" 
> value="customObject"/></s:action>
> {code}
> without conversion customObject->String->customObject.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to