[struts] branch action-context-boost updated: WW-4789 WW-3788 Marks CONVERSION_ERRORS as deprecated on behalf using helper methods

2020-04-10 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch action-context-boost
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/action-context-boost by this 
push:
 new df687a6  WW-4789 WW-3788 Marks CONVERSION_ERRORS as deprecated on 
behalf using helper methods
df687a6 is described below

commit df687a6d43901ef42ff98b01754fc191ec29445f
Author: Lukasz Lenart 
AuthorDate: Fri Apr 10 09:08:38 2020 +0200

WW-4789 WW-3788 Marks CONVERSION_ERRORS as deprecated on behalf using 
helper methods
---
 .../com/opensymphony/xwork2/ActionContext.java |  15 +-
 .../xwork2/conversion/impl/XWorkConverter.java |   5 +-
 .../xwork2/interceptor/AliasInterceptor.java   |   5 +-
 .../xwork2/interceptor/ParametersInterceptor.java  |   5 +-
 .../interceptor/StaticParametersInterceptor.java   |   5 +-
 .../impl/AnnotationXWorkConverterTest.java |  74 +-
 .../xwork2/conversion/impl/XWorkConverterTest.java | 155 +++--
 .../xwork2/ognl/OgnlValueStackTest.java|  51 +++
 8 files changed, 164 insertions(+), 151 deletions(-)

diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java 
b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java
index 3d7b78e..fbc15b9 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java
@@ -63,7 +63,7 @@ public class ActionContext implements Serializable {
 /**
  * Constant for the name of the action being executed.
  *
- * @deprecated used helper methods instead
+ * @deprecated use helper methods instead
  */
 @Deprecated
 public static final String ACTION_NAME = 
"com.opensymphony.xwork2.ActionContext.name";
@@ -100,16 +100,17 @@ public class ActionContext implements Serializable {
 
 /**
  * Constant for the map of type conversion errors.
+ * @deprecated use helper method instead
  */
+@Deprecated
 public static final String CONVERSION_ERRORS = 
"com.opensymphony.xwork2.ActionContext.conversionErrors";
 
-
 /**
  * Constant for the container
  */
 public static final String CONTAINER = 
"com.opensymphony.xwork2.ActionContext.container";
 
-private Map context;
+private final Map context;
 
 /**
  * Creates a new ActionContext initialized with another context.
@@ -128,6 +129,9 @@ public class ActionContext implements Serializable {
  * @return new ActionContext
  */
 public static ActionContext of(Map context) {
+if (context == null) {
+throw new IllegalArgumentException("Context cannot be null!");
+}
 return new ActionContext(context);
 }
 
@@ -223,6 +227,7 @@ public class ActionContext implements Serializable {
  *
  * @return a Map of ServletContext or generic application level Map
  */
+@SuppressWarnings("unchecked")
 public Map getApplication() {
 return (Map) get(APPLICATION);
 }
@@ -258,8 +263,9 @@ public class ActionContext implements Serializable {
  * @return the map of conversion errors which occurred when executing the 
action or an empty map if
  * there were no errors.
  */
+@SuppressWarnings("unchecked")
 public Map getConversionErrors() {
-Map errors = (Map) get(CONVERSION_ERRORS);
+Map errors = (Map) 
get(CONVERSION_ERRORS);
 
 if (errors == null) {
 errors = withConversionErrors(new 
HashMap<>()).getConversionErrors();
@@ -374,6 +380,7 @@ public class ActionContext implements Serializable {
  *
  * @return the Map of HttpSession values when in a servlet environment or 
a generic session map otherwise.
  */
+@SuppressWarnings("unchecked")
 public Map getSession() {
 return (Map) get(SESSION);
 }
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java
 
b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java
index 2a8df11..3cda3e3 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/conversion/impl/XWorkConverter.java
@@ -442,11 +442,12 @@ public class XWorkConverter extends DefaultTypeConverter {
 realProperty = fullName;
 }
 
-Map conversionErrors = (Map) context.get(ActionContext.CONVERSION_ERRORS);
+ActionContext actionContext = ActionContext.of(context);
+Map conversionErrors = 
actionContext.getConversionErrors();
 
 if (conversionErrors == null) {
 conversionErrors = new HashMap<>();
-context.put(ActionContext.CONVERSION_ERRORS, conversionErrors);
+actionContext.withConversionErrors(conversionErrors);
 }
 
 conversionErrors.put(realProperty, new

[struts] branch action-context-boost updated: WW-4789 WW-3788 Marks CONTAINER as deprecated on behalf using helper methods

2020-04-10 Thread lukaszlenart
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch action-context-boost
in repository https://gitbox.apache.org/repos/asf/struts.git


The following commit(s) were added to refs/heads/action-context-boost by this 
push:
 new c253b7f  WW-4789 WW-3788 Marks CONTAINER as deprecated on behalf using 
helper methods
c253b7f is described below

commit c253b7f480c85a554105e3711668a282cca64f93
Author: Lukasz Lenart 
AuthorDate: Fri Apr 10 19:39:10 2020 +0200

WW-4789 WW-3788 Marks CONTAINER as deprecated on behalf using helper methods
---
 .../com/opensymphony/xwork2/ActionContext.java | 19 +++-
 .../xwork2/DefaultActionInvocation.java| 31 --
 .../xwork2/ognl/OgnlValueStackFactory.java | 50 --
 .../opensymphony/xwork2/util/TextParseUtil.java| 10 ++---
 .../xwork2/util/XWorkTestCaseHelper.java   | 15 ++-
 .../struts2/components/ServletUrlRenderer.java |  3 +-
 .../apache/struts2/util/StrutsTestCaseHelper.java  |  5 +--
 .../java/org/apache/struts2/util/StrutsUtil.java   |  6 +--
 .../struts2/views/freemarker/tags/TagModel.java|  2 +-
 .../struts2/views/jsp/ComponentTagSupport.java |  2 +-
 .../org/apache/struts2/views/util/ContextUtil.java | 13 +++---
 .../validator/validators/ValidatorSupportTest.java |  3 +-
 .../struts2/result/ServletRedirectResultTest.java  |  7 ++-
 .../org/apache/struts2/views/jsp/TextTagTest.java  | 37 
 .../apache/struts2/views/jsp/ui/DebugTagTest.java  |  2 +-
 .../apache/struts2/views/util/ContextUtilTest.java |  2 +-
 .../struts2/views/util/DefaultUrlHelperTest.java   |  2 +-
 .../org/apache/struts2/EmbeddedJSPResultTest.java  |  4 +-
 .../struts2/views/java/simple/AbstractTest.java|  8 ++--
 .../struts2/components/PortletUrlRenderer.java |  2 +-
 .../struts2/components/PortletUrlRendererTest.java |  2 +-
 .../velocity/components/AbstractDirective.java |  2 +-
 22 files changed, 128 insertions(+), 99 deletions(-)

diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java 
b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java
index fbc15b9..3c9d0e5 100644
--- a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java
+++ b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java
@@ -63,7 +63,7 @@ public class ActionContext implements Serializable {
 /**
  * Constant for the name of the action being executed.
  *
- * @deprecated use helper methods instead
+ * @deprecated scope will be narrowed to "private", use helper methods 
instead
  */
 @Deprecated
 public static final String ACTION_NAME = 
"com.opensymphony.xwork2.ActionContext.name";
@@ -95,19 +95,23 @@ public class ActionContext implements Serializable {
 
 /**
  * Constant for the action's {@link 
com.opensymphony.xwork2.ActionInvocation invocation} context.
+ * @deprecated scope will be narrowed to "private", use helper methods 
instead
  */
+@Deprecated
 public static final String ACTION_INVOCATION = 
"com.opensymphony.xwork2.ActionContext.actionInvocation";
 
 /**
  * Constant for the map of type conversion errors.
- * @deprecated use helper method instead
+ * @deprecated scope will be narrowed to "private", use helper methods 
instead
  */
 @Deprecated
 public static final String CONVERSION_ERRORS = 
"com.opensymphony.xwork2.ActionContext.conversionErrors";
 
 /**
  * Constant for the container
+ * @deprecated scope will be narrowed to "private", use helper methods 
instead
  */
+@Deprecated
 public static final String CONTAINER = 
"com.opensymphony.xwork2.ActionContext.container";
 
 private final Map context;
@@ -518,4 +522,15 @@ public class ActionContext implements Serializable {
 return this;
 }
 
+public ActionContext withExtraContext(Map extraContext) {
+if (extraContext != null) {
+getContext().context.putAll(extraContext);
+}
+return this;
+}
+
+public ActionContext withLocale(Locale locale) {
+put(LOCALE, locale);
+return this;
+}
 }
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java 
b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
index 215d568..acf7a65 100644
--- a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
+++ b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
@@ -324,9 +324,10 @@ public class DefaultActionInvocation implements 
ActionInvocation {
 }
 
 protected Map createContextMap() {
-Map contextMap;
+ActionContext oldContext = ActionContext.getContext();
+ActionContext actionContext;
 
-if ((extraContext != null) && 
(extraContext.containsKey(ActionContext.VALUE_STACK))) {
+if (extraContext != null && 
extraContext.containsKey(ActionContext.VALUE_STAC