[ 
https://issues.apache.org/jira/browse/WW-5363?focusedWorklogId=890302&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-890302
 ]

ASF GitHub Bot logged work on WW-5363:
--------------------------------------

                Author: ASF GitHub Bot
            Created on: 13/Nov/23 15:00
            Start Date: 13/Nov/23 15:00
    Worklog Time Spent: 10m 
      Work Description: kusalk commented on code in PR #789:
URL: https://github.com/apache/struts/pull/789#discussion_r1391233322


##########
plugins/velocity/src/main/java/org/apache/struts2/views/velocity/StrutsVelocityContext.java:
##########
@@ -54,38 +55,55 @@ public StrutsVelocityContext(ValueStack stack) {
     /**
      * @deprecated please use {@link #StrutsVelocityContext(List, ValueStack)}
      */
-    @Deprecated()
+    @Deprecated
     public StrutsVelocityContext(VelocityContext[] chainedContexts, ValueStack 
stack) {
         this(new ArrayList<>(Arrays.asList(chainedContexts)), stack);
     }
 
+    @Override
     public boolean internalContainsKey(String key) {
         return internalGet(key) != null;
     }
 
+    @Override
     public Object internalGet(String key) {
-        Object val = super.internalGet(key);
-        if (val != null) {
-            return val;
-        }
-        if (stack != null) {
-            val = stack.findValue(key);
+        for (Function<String, Object> contextGet : contextGetterList()) {
+            Object val = contextGet.apply(key);
             if (val != null) {
                 return val;
             }
-            val = stack.getContext().get(key);
+        }
+        return null;
+    }
+
+    protected List<Function<String, Object>> contextGetterList() {
+        return Arrays.asList(super::internalGet, this::chainedContextGet, 
this::stackGet, this::stackContextGet);

Review Comment:
   Happy to revert this back to the original order if you think that's a more 
sensible default





Issue Time Tracking
-------------------

    Worklog Id:     (was: 890302)
    Time Spent: 0.5h  (was: 20m)

> Look up Stack last in Velocity context
> --------------------------------------
>
>                 Key: WW-5363
>                 URL: https://issues.apache.org/jira/browse/WW-5363
>             Project: Struts 2
>          Issue Type: Improvement
>          Components: Plugin - Velocity
>    Affects Versions: 6.3.0
>            Reporter: Kusal Kithul-Godage
>            Priority: Minor
>             Fix For: 6.4.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to