[ 
https://issues.apache.org/jira/browse/WW-5423?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Philip Crider updated WW-5423:
------------------------------
    Description: 
One of the changes in [https://github.com/apache/struts/pull/861] broke query 
parameters in multipart requests. Their values are being lost.

This is the old implementation, which returns null if the parameter doesn't 
exist.
{code:java}
public String[] getParameterValues(String name) {
    List<String> v = params.get(name);
    if (v != null && !v.isEmpty()) {
        return v.toArray(new String[0]);
    }

    return null;
} {code}
 

And this is the new implementation, which returns an empty array in that case.
{code:java}
public String[] getParameterValues(String name) {        
    return parameters.getOrDefault(name, Collections.emptyList())
            .toArray(String[]::new);
}{code}
 

This method in MultiPartRequestWrapper is expecting null to be returned in that 
case.
{code:java}
public String[] getParameterValues(String name) {
    return ((multi == null) || (multi.getParameterValues(name) == null)) ? 
super.getParameterValues(name) : multi.getParameterValues(name);
}{code}
 

 

  was:
One of the changes in [https://github.com/apache/struts/pull/861] broke query 
parameters in multipart requests. Their values are being lost.

 

This is the old implementation, which returns null if the parameter doesn't 
exist.

 
{code:java}
public String[] getParameterValues(String name) {
    List<String> v = params.get(name);
    if (v != null && !v.isEmpty()) {
        return v.toArray(new String[0]);
    }

    return null;
} {code}
 

 

And this is the new implementation, which returns an empty array in that case.

 
{code:java}
public String[] getParameterValues(String name) {        
    return parameters.getOrDefault(name, Collections.emptyList())
            .toArray(String[]::new);
}{code}
 

 

This method in MultiPartRequestWrapper is expecting null to be returned in that 
case.

 
{code:java}
public String[] getParameterValues(String name) {
    return ((multi == null) || (multi.getParameterValues(name) == null)) ? 
super.getParameterValues(name) : multi.getParameterValues(name);
}{code}
 

 


> Query Parameters in Multipart Requests not working in v7 M6
> -----------------------------------------------------------
>
>                 Key: WW-5423
>                 URL: https://issues.apache.org/jira/browse/WW-5423
>             Project: Struts 2
>          Issue Type: Bug
>    Affects Versions: 7.0.0
>            Reporter: Philip Crider
>            Priority: Major
>
> One of the changes in [https://github.com/apache/struts/pull/861] broke query 
> parameters in multipart requests. Their values are being lost.
> This is the old implementation, which returns null if the parameter doesn't 
> exist.
> {code:java}
> public String[] getParameterValues(String name) {
>     List<String> v = params.get(name);
>     if (v != null && !v.isEmpty()) {
>         return v.toArray(new String[0]);
>     }
>     return null;
> } {code}
>  
> And this is the new implementation, which returns an empty array in that case.
> {code:java}
> public String[] getParameterValues(String name) {        
>     return parameters.getOrDefault(name, Collections.emptyList())
>             .toArray(String[]::new);
> }{code}
>  
> This method in MultiPartRequestWrapper is expecting null to be returned in 
> that case.
> {code:java}
> public String[] getParameterValues(String name) {
>     return ((multi == null) || (multi.getParameterValues(name) == null)) ? 
> super.getParameterValues(name) : multi.getParameterValues(name);
> }{code}
>  
>  



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

Reply via email to