This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch feature/WW-5338-remove-ognltool in repository https://gitbox.apache.org/repos/asf/struts.git
commit 400cb242570d9cb51dae1c8708ea62b47005a637 Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Wed Oct 4 13:22:56 2023 +0200 WW-5338 Removes also deprecated constant in ContextUtil --- core/src/main/java/org/apache/struts2/util/StrutsUtil.java | 2 +- core/src/main/java/org/apache/struts2/views/util/ContextUtil.java | 2 -- .../main/java/org/apache/struts2/views/velocity/VelocityManager.java | 4 +--- .../java/org/apache/struts2/views/velocity/VelocityManagerTest.java | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/org/apache/struts2/util/StrutsUtil.java b/core/src/main/java/org/apache/struts2/util/StrutsUtil.java index 13c574fbd..c693599e7 100644 --- a/core/src/main/java/org/apache/struts2/util/StrutsUtil.java +++ b/core/src/main/java/org/apache/struts2/util/StrutsUtil.java @@ -119,8 +119,8 @@ public class StrutsUtil { } public Object findValue(String expr, Object context) { + stack.push(context); try { - stack.push(context); return stack.findValue(expr, true); } finally { stack.pop(); diff --git a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java index 97c148f37..4ab3c2786 100644 --- a/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java +++ b/core/src/main/java/org/apache/struts2/views/util/ContextUtil.java @@ -36,7 +36,6 @@ public class ContextUtil { public static final String SESSION = "session"; public static final String BASE = "base"; public static final String STACK = "stack"; - public static final String OGNL = "ognl"; public static final String STRUTS = "struts"; public static final String ACTION = "action"; @@ -49,7 +48,6 @@ public class ContextUtil { map.put(STACK, stack); StrutsUtil util = new StrutsUtil(stack, req, res); map.put(STRUTS, util); - map.put(OGNL, util); // Deprecated since 6.3.0 ActionInvocation invocation = stack.getActionContext().getActionInvocation(); if (invocation != null) { diff --git a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java index 7acb9bdc1..5cff252e3 100644 --- a/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java +++ b/plugins/velocity/src/main/java/org/apache/struts2/views/velocity/VelocityManager.java @@ -56,8 +56,7 @@ import java.util.Properties; import static java.lang.String.format; import static java.util.Collections.emptyList; import static java.util.stream.Collectors.joining; -import static java.util.stream.Collectors.toList; -import static org.apache.struts2.views.util.ContextUtil.OGNL; +import static java.util.stream.Collectors.toList;; import static org.apache.struts2.views.util.ContextUtil.STRUTS; /** @@ -133,7 +132,6 @@ public class VelocityManager { ContextUtil.getStandardContext(stack, req, res).forEach(context::put); VelocityStrutsUtil util = new VelocityStrutsUtil(velocityEngine, context, stack, req, res); context.put(STRUTS, util); - context.put(OGNL, util); // Deprecated since 6.3.0 return context; } diff --git a/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/VelocityManagerTest.java b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/VelocityManagerTest.java index b86ff2eec..4ff6079b4 100644 --- a/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/VelocityManagerTest.java +++ b/plugins/velocity/src/test/java/org/apache/struts2/views/velocity/VelocityManagerTest.java @@ -94,7 +94,6 @@ public class VelocityManagerTest extends StrutsJUnit4TestCase { assertNotNull(context); assertThat(context.get("struts")).isInstanceOf(VelocityStrutsUtil.class); - assertThat(context.get("ognl")).isInstanceOf(VelocityStrutsUtil.class); // Deprecated since 6.3.0 assertThat(context.get("stack")).isInstanceOf(ValueStack.class); assertThat(context.get("request")).isInstanceOf(HttpServletRequest.class); assertThat(context.get("response")).isInstanceOf(HttpServletResponse.class);