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

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

                Author: ASF GitHub Bot
            Created on: 15/Nov/20 01:11
            Start Date: 15/Nov/20 01:11
    Worklog Time Spent: 10m 
      Work Description: JCgH4164838Gh792C124B5 commented on pull request #446:
URL: https://github.com/apache/struts/pull/446#issuecomment-727290131


   Hi @lukaszlenart  and @akash5885 .
   
   It looks like the original code of `StaticParametersInterceptor` 
`addParametersToContext()` was doing the same operations if `overwrite` was 
`true `or `false`, just in reverse-order depending on the `boolean `value. I 
think that was what @akash5885 stated in the JIRA ?
   
   Did the different ordering of the old code blocks have any effect at all, or 
was the end result the same whether `overwrite` was `true` or `false` ?
   
   Is there a possibility for a manual test example or test case that clarifies 
how the original code was not working as intended, and how the updated code 
does ?
   
   I am not sure I am understanding the original problem correctly, so I 
figured I would ask.  😄 


----------------------------------------------------------------
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: 511818)
    Time Spent: 40m  (was: 0.5h)

> Struts2 StaticParametersInterceptor's addParametersToContext method is not 
> working as expected.
> -----------------------------------------------------------------------------------------------
>
>                 Key: WW-5096
>                 URL: https://issues.apache.org/jira/browse/WW-5096
>             Project: Struts 2
>          Issue Type: Bug
>            Reporter: Akash Shah
>            Priority: Minor
>             Fix For: 2.5.26, 2.6
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> In our current project we are upgrading struts 2.3.35 to 2.5.22 and we 
> encounter some minor bug in below code of addParametersToContext method of 
> StaticParametersInterceptor.
> in method, code is like below.
>  
> {code:java}
> if (overwrite) {
>             if (previousParams != null) {
>                 combinedParams = combinedParams.withParent(previousParams);
>             }
>             if (newParams != null) {
>                 combinedParams = combinedParams.withExtraParams(newParams);
>             }
>         } else {
>             if (newParams != null) {
>                 combinedParams = combinedParams.withExtraParams(newParams);
>             }
>             if (previousParams != null) {
>                 combinedParams = combinedParams.withParent(previousParams);
>             }
>         }
> {code}
>  
> But here overwrite functionality will not work since only if condition order 
> was changed in else condition of overwrite.
> instead of this, as per me, code would be like below
> {code:java}
> if (overwrite) {
>             if (previousParams != null) {
>                 combinedParams = combinedParams.withParent(previousParams);
>             }
>             if (newParams != null) {
>                 combinedParams = combinedParams.withExtraParams(newParams);
>             }
>         } else {
>             if (newParams != null) {  
>              HttpParameters newHttpParameters = 
> HttpParameters.create(newParams).build();
>                 combinedParams = combinedParams.withParent(newParams);
>             }
>             if (previousParams != null) {
>                 combinedParams = 
> combinedParams.withExtraParams(previousParams);
>             }
>         }
> {code}
>  
> And that's how ac.setParameters(combinedParams.build()); will work because in 
> build method, requestParameterMap will override parent parameters.
>  



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

Reply via email to