You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2020/11/13 16:21:00 UTC
[jira] [Commented] (WW-5096) Struts2 StaticParametersInterceptor's addParametersToContext method is not working as expected.
[ https://issues.apache.org/jira/browse/WW-5096?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17231600#comment-17231600 ]
ASF subversion and git services commented on WW-5096:
-----------------------------------------------------
Commit 9ed004f6130439e0dbd79a114c7e0b4298dabc21 in struts's branch refs/heads/WW-5096-fix-static from Lukasz Lenart
[ https://gitbox.apache.org/repos/asf?p=struts.git;h=9ed004f ]
WW-5096 Fixes params overwriting
> 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
>
>
> 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)