struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [struts] 02/13: Avoids parsing namespace when using existing namespace
Date Fri, 24 Aug 2018 08:34:27 GMT
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

commit 2877a656e0b17c4cebf5518e4cf3dd40edb485d3
Author: Lukasz Lenart <lukaszlenart@apache.org>
AuthorDate: Wed May 2 08:04:15 2018 +0200

    Avoids parsing namespace when using existing namespace
---
 .../src/main/java/com/opensymphony/xwork2/ActionChainResult.java | 9 +++------
 core/src/main/java/org/apache/struts2/result/PostbackResult.java | 1 +
 .../org/apache/struts2/result/ServletActionRedirectResult.java   | 1 +
 .../main/java/org/apache/struts2/result/StrutsResultSupport.java | 4 +++-
 .../struts2/portlet/result/PortletActionRedirectResult.java      | 1 +
 5 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionChainResult.java b/core/src/main/java/com/opensymphony/xwork2/ActionChainResult.java
index 1550eb9..b842897 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ActionChainResult.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ActionChainResult.java
@@ -201,13 +201,10 @@ public class ActionChainResult implements Result {
      * @param invocation the DefaultActionInvocation calling the action call stack
      */
     public void execute(ActionInvocation invocation) throws Exception {
-        // if the finalNamespace wasn't explicitly defined, assume the current one
-        if (this.namespace == null) {
-            this.namespace = invocation.getProxy().getNamespace();
-        }
-
         ValueStack stack = ActionContext.getContext().getValueStack();
-        String finalNamespace = TextParseUtil.translateVariables(namespace, stack);
+        String finalNamespace = this.namespace != null
+                ? TextParseUtil.translateVariables(namespace, stack)
+                : invocation.getProxy().getNamespace();
         String finalActionName = TextParseUtil.translateVariables(actionName, stack);
         String finalMethodName = this.methodName != null
                 ? TextParseUtil.translateVariables(this.methodName, stack)
diff --git a/core/src/main/java/org/apache/struts2/result/PostbackResult.java b/core/src/main/java/org/apache/struts2/result/PostbackResult.java
index d040fbb..4c1e52a 100644
--- a/core/src/main/java/org/apache/struts2/result/PostbackResult.java
+++ b/core/src/main/java/org/apache/struts2/result/PostbackResult.java
@@ -136,6 +136,7 @@ public class PostbackResult extends StrutsResultSupport {
             actionName = conditionalParse(actionName, invocation);
             if (namespace == null) {
                 namespace = invocation.getProxy().getNamespace();
+                parseLocation = false;
             } else {
                 namespace = conditionalParse(namespace, invocation);
             }
diff --git a/core/src/main/java/org/apache/struts2/result/ServletActionRedirectResult.java
b/core/src/main/java/org/apache/struts2/result/ServletActionRedirectResult.java
index b5356ad..5b800e2 100644
--- a/core/src/main/java/org/apache/struts2/result/ServletActionRedirectResult.java
+++ b/core/src/main/java/org/apache/struts2/result/ServletActionRedirectResult.java
@@ -161,6 +161,7 @@ public class ServletActionRedirectResult extends ServletRedirectResult
implement
         actionName = conditionalParse(actionName, invocation);
         if (namespace == null) {
             namespace = invocation.getProxy().getNamespace();
+            parseLocation = false;
         } else {
             namespace = conditionalParse(namespace, invocation);
         }
diff --git a/core/src/main/java/org/apache/struts2/result/StrutsResultSupport.java b/core/src/main/java/org/apache/struts2/result/StrutsResultSupport.java
index a21e095..d5307d2 100644
--- a/core/src/main/java/org/apache/struts2/result/StrutsResultSupport.java
+++ b/core/src/main/java/org/apache/struts2/result/StrutsResultSupport.java
@@ -122,6 +122,8 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics
{
     /** use UTF-8 as this is the recommended encoding by W3C to avoid incompatibilities.
*/
     public static final String DEFAULT_URL_ENCODING = "UTF-8";
 
+    protected boolean parseLocation = true;
+
     private boolean parse;
     private boolean encode;
     private String location;
@@ -200,7 +202,7 @@ public abstract class StrutsResultSupport implements Result, StrutsStatics
{
      * @throws Exception if an error occurs while executing the result.
      */
     public void execute(ActionInvocation invocation) throws Exception {
-        lastFinalLocation = conditionalParse(location, invocation);
+        lastFinalLocation = parseLocation ? conditionalParse(location, invocation) : location;
         doExecute(lastFinalLocation, invocation);
     }
 
diff --git a/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java
b/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java
index 4b561ca..db4f98a 100644
--- a/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java
+++ b/plugins/portlet/src/main/java/org/apache/struts2/portlet/result/PortletActionRedirectResult.java
@@ -179,6 +179,7 @@ public class PortletActionRedirectResult extends PortletResult {
 		}
 		if (namespace == null) {
 			namespace = invocation.getProxy().getNamespace();
+			parseLocation = false;
 		} else {
 			namespace = conditionalParse(namespace, invocation);
 		}


Mime
View raw message