[struts] branch master updated: Forward port fix for WW-5024 to 2.6: - NOTE: If the PR is accepted please credit Robert Hollencamp (Github @rhollencamp) for this change as he found the issue, proposed
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/master by this push: new 3e11e1d Forward port fix for WW-5024 to 2.6: - NOTE: If the PR is accepted please credit Robert Hollencamp (Github @rhollencamp) for this change as he found the issue, proposed a solution for 2.6 (master), and opened the JIRA. - Updated HttpParameters, ActionMappingParametersInterceptor to prevent multi-level Parameter wrapping from occuring. - Updated HttpParameters create(), build() and buildNoNestedWrapping() to replace redundant type operators with <> based on IDE hi [...] new 91c6a6f Merge pull request #346 from JCgH4164838Gh792C124B5/localS2_26x_B4 3e11e1d is described below commit 3e11e1db4775a5f4f21d57f0361ea06ed06e1578 Author: JCgH4164838Gh792C124B5 <43964333+jcgh4164838gh792c12...@users.noreply.github.com> AuthorDate: Sun Mar 31 23:44:40 2019 -0400 Forward port fix for WW-5024 to 2.6: - NOTE: If the PR is accepted please credit Robert Hollencamp (Github @rhollencamp) for this change as he found the issue, proposed a solution for 2.6 (master), and opened the JIRA. - Updated HttpParameters, ActionMappingParametersInterceptor to prevent multi-level Parameter wrapping from occuring. - Updated HttpParameters create(), build() and buildNoNestedWrapping() to replace redundant type operators with <> based on IDE hint. - Made HttpParameters parameters member final based on IDE hint. - Added a new ActionMappingParametersInterceptorTest to verify the fix. --- .../apache/struts2/dispatcher/HttpParameters.java | 29 ++- .../ActionMappingParametersInterceptor.java| 16 +- .../ActionMappingParametersInterceptorTest.java| 199 + 3 files changed, 233 insertions(+), 11 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java b/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java index 6bf35a9..d17b71c 100644 --- a/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java +++ b/core/src/main/java/org/apache/struts2/dispatcher/HttpParameters.java @@ -33,7 +33,7 @@ import java.util.TreeSet; @SuppressWarnings("unchecked") public class HttpParameters implements Map, Cloneable { -private Map parameters; +final private Map parameters; private HttpParameters(Map parameters) { this.parameters = parameters; @@ -44,7 +44,7 @@ public class HttpParameters implements Map, Cloneable { } public static Builder create() { -return new Builder(new HashMap()); +return new Builder(new HashMap<>()); } public HttpParameters remove(Set paramsToRemove) { @@ -183,7 +183,7 @@ public class HttpParameters implements Map, Cloneable { public HttpParameters build() { Map parameters = (parent == null) -? new HashMap() +? new HashMap<>() : new HashMap<>(parent.parameters); for (Map.Entry entry : requestParameterMap.entrySet()) { @@ -194,5 +194,28 @@ public class HttpParameters implements Map, Cloneable { return new HttpParameters(parameters); } + +/** +* Alternate Builder method which avoids wrapping any parameters that are already +* a {@link Parameter} element within another {@link Parameter} wrapper. +* +* @return + */ +public HttpParameters buildNoNestedWrapping() { +Map parameters = (parent == null) +? new HashMap<>() +: new HashMap<>(parent.parameters); + +for (Map.Entry entry : requestParameterMap.entrySet()) { +String name = entry.getKey(); +Object value = entry.getValue(); +Parameter parameterValue = (value instanceof Parameter) +? (Parameter) value +: new Parameter.Request(name, value); +parameters.put(name, parameterValue); +} + +return new HttpParameters(parameters); +} } } diff --git a/core/src/main/java/org/apache/struts2/interceptor/ActionMappingParametersInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/ActionMappingParametersInterceptor.java index 967f748..2b04795 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/ActionMappingParametersInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/ActionMappingParametersInterceptor.java @@ -74,6 +74,8 @@ import java.util.Map; public class ActionMappingParametersInterceptor extends ParametersInterceptor { /** + * Get the parameter map from ActionMapping associated with the provided ActionContext. + * * @param ac The action context
[struts] branch master updated: Forward-port fix for WW-5026 to 2.6. - Equivalent to PR#342 for 2.5.x, fixes double-submit error 500 failure with - Fixes error 500 processing failures for double-submi
This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts.git The following commit(s) were added to refs/heads/master by this push: new bb7cf09 Forward-port fix for WW-5026 to 2.6. - Equivalent to PR#342 for 2.5.x, fixes double-submit error 500 failure with - Fixes error 500 processing failures for double-submit results with TokenSessionStoreInterceptor processing - Fix to InvocationSessionStore, new unit test confirming fix in InvocationSessionStoreTest - Minor whitespace fix to TokenSessionStoreInterceptor new f251d1c Merge pull request #345 from JCgH4164838Gh792C124B5/localS2_26x_B3 bb7cf09 is described below commit bb7cf092bc9374af743de67ec9e2aa4d0f55cdf0 Author: JCgH4164838Gh792C124B5 <43964333+jcgh4164838gh792c12...@users.noreply.github.com> AuthorDate: Sun Mar 31 22:47:16 2019 -0400 Forward-port fix for WW-5026 to 2.6. - Equivalent to PR#342 for 2.5.x, fixes double-submit error 500 failure with - Fixes error 500 processing failures for double-submit results with TokenSessionStoreInterceptor processing - Fix to InvocationSessionStore, new unit test confirming fix in InvocationSessionStoreTest - Minor whitespace fix to TokenSessionStoreInterceptor --- .../interceptor/TokenSessionStoreInterceptor.java | 26 +- .../struts2/util/InvocationSessionStore.java | 20 ++ .../struts2/util/InvocationSessionStoreTest.java | 31 ++ 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java index e08fb07..863e804 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/TokenSessionStoreInterceptor.java @@ -112,6 +112,20 @@ public class TokenSessionStoreInterceptor extends TokenInterceptor { } } +/** + * Handles processing of invalid tokens. If a previously stored invocation is + * available, the method will attempt to return and render its result. Otherwise + * it will return INVALID_TOKEN_CODE. + * + * Note: Because a stored (previously completed) invocation's PageContext will be closed, + * this method must replace the stored PageContext with the current invocation's one (or a null). + * See {@link org.apache.struts2.util.InvocationSessionStore#loadInvocation(String key, String token)} for details. + * + * @param invocation + * + * @return + * @throws Exception + */ @Override protected String handleInvalidToken(ActionInvocation invocation) throws Exception { ActionContext ac = invocation.getInvocationContext(); @@ -130,7 +144,7 @@ public class TokenSessionStoreInterceptor extends TokenInterceptor { ActionInvocation savedInvocation = InvocationSessionStore.loadInvocation(sessionTokenName, token); if (savedInvocation != null) { -// set the valuestack to the request scope +// set the savedInvocation's valuestack to the request scope ValueStack stack = savedInvocation.getStack(); request.setAttribute(ServletActionContext.STRUTS_VALUESTACK_KEY, stack); @@ -153,6 +167,16 @@ public class TokenSessionStoreInterceptor extends TokenInterceptor { return INVALID_TOKEN_CODE; } +/** + * Handles processing of valid tokens. Stores the current invocation for + * later use by {@link handleInvalidToken}. + * See {@link org.apache.struts2.util.InvocationSessionStore#storeInvocation(String key, String token, ActionInvocation invocation)} for details. + * + * @param invocation + * + * @return + * @throws Exception + */ @Override protected String handleValidToken(ActionInvocation invocation) throws Exception { // we know the token name and token must be there diff --git a/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java b/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java index 15662de..238df3c 100644 --- a/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java +++ b/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java @@ -20,6 +20,7 @@ package org.apache.struts2.util; import com.opensymphony.xwork2.ActionContext; import com.opensymphony.xwork2.ActionInvocation; +import org.apache.struts2.ServletActionContext; import java.io.Serializable; import java.util.HashMap; @@ -55,11 +56,20 @@ public class InvocationSessionStore { return null; } -ActionInvocation savedInvocation = null; -if (invocationContext.invocation != null) { -