This is an automated email from the ASF dual-hosted git repository.

kusal pushed a commit to branch WW-5610-extend-forwards-compat
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 87d8feaa8f6679fa6229b6485ab0c6d60364a1d2
Author: Kusal Kithul-Godage <[email protected]>
AuthorDate: Mon Feb 2 18:27:01 2026 +1100

    WW-5610 Extend Struts 7 forwards compat to more interceptors
---
 .../interceptor/MethodFilterInterceptor.java       | 11 ++++--
 .../xwork2/validator/ValidationInterceptor.java    |  6 +++-
 .../struts2/interceptor/TokenInterceptor.java      | 42 +++++++++++++++-------
 .../struts2/util/InvocationSessionStore.java       | 12 ++++---
 4 files changed, 51 insertions(+), 20 deletions(-)

diff --git 
a/core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptor.java
 
b/core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptor.java
index bcce3da12..ebea65797 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptor.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptor.java
@@ -98,8 +98,8 @@ public abstract class MethodFilterInterceptor extends 
AbstractInterceptor {
 
     @Override
     public String intercept(ActionInvocation invocation) throws Exception {
-        if (applyInterceptor(invocation)) {
-            return doIntercept(invocation);
+        if (applyInterceptor((org.apache.struts2.ActionInvocation) 
invocation)) {
+            return doIntercept((org.apache.struts2.ActionInvocation) 
invocation);
         }
         return invocation.invoke();
     }
@@ -114,6 +114,10 @@ public abstract class MethodFilterInterceptor extends 
AbstractInterceptor {
         return applyMethod;
     }
 
+    protected boolean applyInterceptor(org.apache.struts2.ActionInvocation 
invocation) {
+        return applyInterceptor(ActionInvocation.adapt(invocation));
+    }
+
     /**
      * Subclasses must override to implement the interceptor logic.
      *
@@ -123,4 +127,7 @@ public abstract class MethodFilterInterceptor extends 
AbstractInterceptor {
      */
     protected abstract String doIntercept(ActionInvocation invocation) throws 
Exception;
 
+    protected String doIntercept(org.apache.struts2.ActionInvocation 
invocation) throws Exception {
+        return doIntercept(ActionInvocation.adapt(invocation));
+    }
 }
diff --git 
a/core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java
 
b/core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java
index cc22250e3..f9817d1c6 100644
--- 
a/core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/validator/ValidationInterceptor.java
@@ -257,9 +257,13 @@ public class ValidationInterceptor extends 
MethodFilterInterceptor {
         }
     }
 
+    protected void doBeforeInvocation(org.apache.struts2.ActionInvocation 
invocation) throws Exception {
+        doBeforeInvocation(ActionInvocation.adapt(invocation));
+    }
+
     @Override
     protected String doIntercept(ActionInvocation invocation) throws Exception 
{
-        doBeforeInvocation(invocation);
+        doBeforeInvocation((org.apache.struts2.ActionInvocation) invocation);
         return invocation.invoke();
     }
 
diff --git 
a/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java 
b/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java
index b67ef6422..d88a6ad38 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/TokenInterceptor.java
@@ -135,7 +135,7 @@ public class TokenInterceptor extends 
MethodFilterInterceptor {
     @Override
     protected String doIntercept(ActionInvocation invocation) throws Exception 
{
         LOG.debug("Intercepting invocation to check for valid transaction 
token.");
-        return handleToken(invocation);
+        return handleToken((org.apache.struts2.ActionInvocation) invocation);
     }
 
     protected String handleToken(ActionInvocation invocation) throws Exception 
{
@@ -144,22 +144,19 @@ public class TokenInterceptor extends 
MethodFilterInterceptor {
         HttpSession session = 
ServletActionContext.getRequest().getSession(true);
         synchronized (session.getId().intern()) {
             if (!TokenHelper.validToken()) {
-                return handleInvalidToken(invocation);
+                return 
handleInvalidToken((org.apache.struts2.ActionInvocation) invocation);
             }
         }
-        return handleValidToken(invocation);
+        return handleValidToken((org.apache.struts2.ActionInvocation) 
invocation);
+    }
+
+    protected String handleToken(org.apache.struts2.ActionInvocation 
invocation) throws Exception {
+        return handleToken(ActionInvocation.adapt(invocation));
     }
 
-    /**
-     * Determines what to do if an invalid token is provided. If the action 
implements {@link ValidationAware}
-     *
-     * @param invocation the action invocation where the invalid token failed
-     * @return the return code to indicate should be processed
-     * @throws Exception when any unexpected error occurs.
-     */
     protected String handleInvalidToken(ActionInvocation invocation) throws 
Exception {
         Object action = invocation.getAction();
-        String errorMessage = getErrorMessage(invocation);
+        String errorMessage = 
getErrorMessage((org.apache.struts2.ActionInvocation) invocation);
 
         if (action instanceof ValidationAware) {
             ((ValidationAware) action).addActionError(errorMessage);
@@ -170,6 +167,17 @@ public class TokenInterceptor extends 
MethodFilterInterceptor {
         return INVALID_TOKEN_CODE;
     }
 
+    /**
+     * Determines what to do if an invalid token is provided. If the action 
implements {@link ValidationAware}
+     *
+     * @param invocation the action invocation where the invalid token failed
+     * @return the return code to indicate should be processed
+     * @throws Exception when any unexpected error occurs.
+     */
+    protected String handleInvalidToken(org.apache.struts2.ActionInvocation 
invocation) throws Exception {
+        return handleInvalidToken(ActionInvocation.adapt(invocation));
+    }
+
     protected String getErrorMessage(ActionInvocation invocation) {
         Object action = invocation.getAction();
         if (action instanceof TextProvider) {
@@ -178,6 +186,14 @@ public class TokenInterceptor extends 
MethodFilterInterceptor {
         return textProvider.getText(INVALID_TOKEN_MESSAGE_KEY, 
DEFAULT_ERROR_MESSAGE);
     }
 
+    protected String getErrorMessage(org.apache.struts2.ActionInvocation 
invocation) {
+        return getErrorMessage(ActionInvocation.adapt(invocation));
+    }
+
+    protected String handleValidToken(ActionInvocation invocation) throws 
Exception {
+        return invocation.invoke();
+    }
+
     /**
      * Called when a valid token is found. This method invokes the action by 
can be changed to do something more
      * interesting.
@@ -186,8 +202,8 @@ public class TokenInterceptor extends 
MethodFilterInterceptor {
      * @return invocation result
      * @throws Exception when any unexpected error occurs.
      */
-    protected String handleValidToken(ActionInvocation invocation) throws 
Exception {
-        return invocation.invoke();
+    protected String handleValidToken(org.apache.struts2.ActionInvocation 
invocation) throws Exception {
+        return handleValidToken(ActionInvocation.adapt(invocation));
     }
 
 }
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 c9fe66e8e..301c32cab 100644
--- a/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java
+++ b/core/src/main/java/org/apache/struts2/util/InvocationSessionStore.java
@@ -55,7 +55,7 @@ public class InvocationSessionStore {
             return null;
         }
 
-        final ActionInvocation savedInvocation = invocationContext.invocation;
+        final ActionInvocation savedInvocation = 
ActionInvocation.adapt(invocationContext.invocation);
         if (savedInvocation != null) {
             // WW-5026 - Preserve the previous PageContext (even if null) and 
restore it to the
             // ActionContext after loading the savedInvocation context.  The 
saved context's PageContext
@@ -72,6 +72,10 @@ public class InvocationSessionStore {
         return savedInvocation;
     }
 
+    public static void storeInvocation(String key, String token, 
ActionInvocation invocation) {
+        storeInvocation(key, token, (org.apache.struts2.ActionInvocation) 
invocation);
+    }
+
     /**
      * Stores the DefaultActionInvocation and ActionContext into the Session 
using the provided key for loading later using
      * {@link #loadInvocation}
@@ -80,7 +84,7 @@ public class InvocationSessionStore {
      * @param token token for check
      * @param invocation the action invocation
      */
-    public static void storeInvocation(String key, String token, 
ActionInvocation invocation) {
+    public static void storeInvocation(String key, String token, 
org.apache.struts2.ActionInvocation invocation) {
         InvocationContext invocationContext = new 
InvocationContext(invocation, token);
         Map<String, Object> invocationMap = getInvocationMap();
         invocationMap.put(key, invocationContext);
@@ -120,11 +124,11 @@ public class InvocationSessionStore {
         private static final long serialVersionUID = -286697666275777888L;
 
         //WW-4873 transient since 2.5.15
-        transient ActionInvocation invocation;
+        transient org.apache.struts2.ActionInvocation invocation;
 
         String token;
 
-        public InvocationContext(ActionInvocation invocation, String token) {
+        public InvocationContext(org.apache.struts2.ActionInvocation 
invocation, String token) {
             this.invocation = invocation;
             this.token = token;
         }

Reply via email to