From a74f399397aed38131d7178d38dca8abc01f9fd4 Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Thu, 17 Oct 2024 16:51:29 +1100 Subject: [PATCH] WW-3714 Shortcut adapters --- core/src/main/java/com/opensymphony/xwork2/ActionContext.java | 3 +++ .../main/java/com/opensymphony/xwork2/ActionEventListener.java | 3 +++ .../main/java/com/opensymphony/xwork2/ActionInvocation.java | 3 +++ core/src/main/java/com/opensymphony/xwork2/ActionProxy.java | 3 +++ core/src/main/java/com/opensymphony/xwork2/Result.java | 3 +++ .../com/opensymphony/xwork2/interceptor/PreResultListener.java | 3 +++ .../src/main/java/com/opensymphony/xwork2/util/ValueStack.java | 3 +++ 7 files changed, 21 insertions(+) diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java index 1e6d1efbd1..ac9026b6f4 100644 --- a/core/src/main/java/com/opensymphony/xwork2/ActionContext.java +++ b/core/src/main/java/com/opensymphony/xwork2/ActionContext.java @@ -44,6 +44,9 @@ private ActionContext(org.apache.struts2.ActionContext actualContext) { } public static ActionContext adapt(org.apache.struts2.ActionContext actualContext) { + if (actualContext instanceof ActionContext) { + return (ActionContext) actualContext; + } return actualContext != null ? new ActionContext(actualContext) : null; } diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionEventListener.java b/core/src/main/java/com/opensymphony/xwork2/ActionEventListener.java index 5bd4f86d5a..28d46e9923 100644 --- a/core/src/main/java/com/opensymphony/xwork2/ActionEventListener.java +++ b/core/src/main/java/com/opensymphony/xwork2/ActionEventListener.java @@ -43,6 +43,9 @@ default String handleException(Throwable t, org.apache.struts2.util.ValueStack s String handleException(Throwable t, ValueStack stack); static ActionEventListener adapt(org.apache.struts2.ActionEventListener actualListener) { + if (actualListener instanceof ActionEventListener) { + return (ActionEventListener) actualListener; + } return actualListener != null ? new LegacyAdapter(actualListener) : null; } diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionInvocation.java b/core/src/main/java/com/opensymphony/xwork2/ActionInvocation.java index 76929a647f..81e55d592d 100644 --- a/core/src/main/java/com/opensymphony/xwork2/ActionInvocation.java +++ b/core/src/main/java/com/opensymphony/xwork2/ActionInvocation.java @@ -63,6 +63,9 @@ default void init(org.apache.struts2.ActionProxy proxy) { void init(ActionProxy proxy); static ActionInvocation adapt(org.apache.struts2.ActionInvocation actualInvocation) { + if (actualInvocation instanceof ActionInvocation) { + return (ActionInvocation) actualInvocation; + } return actualInvocation != null ? new LegacyAdapter(actualInvocation) : null; } diff --git a/core/src/main/java/com/opensymphony/xwork2/ActionProxy.java b/core/src/main/java/com/opensymphony/xwork2/ActionProxy.java index 18a1e6a6e3..c3905a1a09 100644 --- a/core/src/main/java/com/opensymphony/xwork2/ActionProxy.java +++ b/core/src/main/java/com/opensymphony/xwork2/ActionProxy.java @@ -27,6 +27,9 @@ public interface ActionProxy extends org.apache.struts2.ActionProxy { ActionInvocation getInvocation(); static ActionProxy adapt(org.apache.struts2.ActionProxy actualProxy) { + if (actualProxy instanceof ActionProxy) { + return (ActionProxy) actualProxy; + } return actualProxy != null ? new LegacyAdapter(actualProxy) : null; } diff --git a/core/src/main/java/com/opensymphony/xwork2/Result.java b/core/src/main/java/com/opensymphony/xwork2/Result.java index 294ada4d71..36a93438a7 100644 --- a/core/src/main/java/com/opensymphony/xwork2/Result.java +++ b/core/src/main/java/com/opensymphony/xwork2/Result.java @@ -34,6 +34,9 @@ default void execute(org.apache.struts2.ActionInvocation invocation) throws Exce void execute(ActionInvocation invocation) throws Exception; static Result adapt(org.apache.struts2.Result actualResult) { + if (actualResult instanceof Result) { + return (Result) actualResult; + } return actualResult != null ? new LegacyAdapter(actualResult) : null; } diff --git a/core/src/main/java/com/opensymphony/xwork2/interceptor/PreResultListener.java b/core/src/main/java/com/opensymphony/xwork2/interceptor/PreResultListener.java index 469d3521bd..25ba59a42c 100644 --- a/core/src/main/java/com/opensymphony/xwork2/interceptor/PreResultListener.java +++ b/core/src/main/java/com/opensymphony/xwork2/interceptor/PreResultListener.java @@ -36,6 +36,9 @@ default void beforeResult(org.apache.struts2.ActionInvocation invocation, String void beforeResult(ActionInvocation invocation, String resultCode); static PreResultListener adapt(org.apache.struts2.interceptor.PreResultListener actualListener) { + if (actualListener instanceof PreResultListener) { + return (PreResultListener) actualListener; + } return actualListener != null ? new LegacyAdapter(actualListener) : null; } diff --git a/core/src/main/java/com/opensymphony/xwork2/util/ValueStack.java b/core/src/main/java/com/opensymphony/xwork2/util/ValueStack.java index 9e3e98b57b..22f5bc428b 100644 --- a/core/src/main/java/com/opensymphony/xwork2/util/ValueStack.java +++ b/core/src/main/java/com/opensymphony/xwork2/util/ValueStack.java @@ -32,6 +32,9 @@ public interface ValueStack extends org.apache.struts2.util.ValueStack { ActionContext getActionContext(); static ValueStack adapt(org.apache.struts2.util.ValueStack actualStack) { + if (actualStack instanceof ValueStack) { + return (ValueStack) actualStack; + } return actualStack != null ? new LegacyAdapter(actualStack) : null; }