From d351843ecd0a41207198cb64b801df7af6d945ff Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Sat, 2 Nov 2024 23:01:07 +1100 Subject: [PATCH] WW-3714 Move new Result class into result package --- core/src/main/java/com/opensymphony/xwork2/Result.java | 10 +++++----- .../xwork2/factory/DefaultResultFactory.java | 4 ++-- .../main/java/org/apache/struts2/ActionInvocation.java | 1 + .../apache/struts2/factory/StrutsResultFactory.java | 4 ++-- .../struts2/interceptor/ChainingInterceptor.java | 2 +- .../java/org/apache/struts2/{ => result}/Result.java | 5 ++++- .../ConfigurationProviderOgnlAllowlistTest.java | 6 +++--- 7 files changed, 18 insertions(+), 14 deletions(-) rename core/src/main/java/org/apache/struts2/{ => result}/Result.java (93%) diff --git a/core/src/main/java/com/opensymphony/xwork2/Result.java b/core/src/main/java/com/opensymphony/xwork2/Result.java index 36a93438a7..f2e74d0347 100644 --- a/core/src/main/java/com/opensymphony/xwork2/Result.java +++ b/core/src/main/java/com/opensymphony/xwork2/Result.java @@ -21,10 +21,10 @@ /** * {@inheritDoc} * - * @deprecated since 6.7.0, use {@link org.apache.struts2.Result} instead. + * @deprecated since 6.7.0, use {@link org.apache.struts2.result.Result} instead. */ @Deprecated -public interface Result extends org.apache.struts2.Result { +public interface Result extends org.apache.struts2.result.Result { @Override default void execute(org.apache.struts2.ActionInvocation invocation) throws Exception { @@ -33,7 +33,7 @@ default void execute(org.apache.struts2.ActionInvocation invocation) throws Exce void execute(ActionInvocation invocation) throws Exception; - static Result adapt(org.apache.struts2.Result actualResult) { + static Result adapt(org.apache.struts2.result.Result actualResult) { if (actualResult instanceof Result) { return (Result) actualResult; } @@ -42,9 +42,9 @@ static Result adapt(org.apache.struts2.Result actualResult) { class LegacyAdapter implements Result { - private final org.apache.struts2.Result adaptee; + private final org.apache.struts2.result.Result adaptee; - private LegacyAdapter(org.apache.struts2.Result adaptee) { + private LegacyAdapter(org.apache.struts2.result.Result adaptee) { this.adaptee = adaptee; } diff --git a/core/src/main/java/com/opensymphony/xwork2/factory/DefaultResultFactory.java b/core/src/main/java/com/opensymphony/xwork2/factory/DefaultResultFactory.java index b4e312bfd8..f4b673dd36 100644 --- a/core/src/main/java/com/opensymphony/xwork2/factory/DefaultResultFactory.java +++ b/core/src/main/java/com/opensymphony/xwork2/factory/DefaultResultFactory.java @@ -73,8 +73,8 @@ public Result buildResult(ResultConfig resultConfig, Map extraCo if (o instanceof Result) { result = (Result) o; - } else if (o instanceof org.apache.struts2.Result) { - result = Result.adapt((org.apache.struts2.Result) o); + } else if (o instanceof org.apache.struts2.result.Result) { + result = Result.adapt((org.apache.struts2.result.Result) o); } if (result == null) { throw new ConfigurationException("Class [" + resultClassName + "] does not implement Result", resultConfig); diff --git a/core/src/main/java/org/apache/struts2/ActionInvocation.java b/core/src/main/java/org/apache/struts2/ActionInvocation.java index 5fcbc75ec9..2a90a06b43 100644 --- a/core/src/main/java/org/apache/struts2/ActionInvocation.java +++ b/core/src/main/java/org/apache/struts2/ActionInvocation.java @@ -20,6 +20,7 @@ import com.opensymphony.xwork2.ActionChainResult; import org.apache.struts2.interceptor.PreResultListener; +import org.apache.struts2.result.Result; import org.apache.struts2.util.ValueStack; /** diff --git a/core/src/main/java/org/apache/struts2/factory/StrutsResultFactory.java b/core/src/main/java/org/apache/struts2/factory/StrutsResultFactory.java index 8a653bdaf3..79a5ff1699 100644 --- a/core/src/main/java/org/apache/struts2/factory/StrutsResultFactory.java +++ b/core/src/main/java/org/apache/struts2/factory/StrutsResultFactory.java @@ -61,8 +61,8 @@ public Result buildResult(ResultConfig resultConfig, Map extraCo } if (o instanceof Result) { result = (Result) o; - } else if (o instanceof org.apache.struts2.Result) { - result = Result.adapt((org.apache.struts2.Result) o); + } else if (o instanceof org.apache.struts2.result.Result) { + result = Result.adapt((org.apache.struts2.result.Result) o); } if (result == null) { throw new ConfigurationException("Class [" + resultClassName + "] does not implement Result", resultConfig); diff --git a/core/src/main/java/org/apache/struts2/interceptor/ChainingInterceptor.java b/core/src/main/java/org/apache/struts2/interceptor/ChainingInterceptor.java index fd3c25a65d..aae3077c42 100644 --- a/core/src/main/java/org/apache/struts2/interceptor/ChainingInterceptor.java +++ b/core/src/main/java/org/apache/struts2/interceptor/ChainingInterceptor.java @@ -27,9 +27,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.struts2.ActionInvocation; -import org.apache.struts2.Result; import org.apache.struts2.StrutsConstants; import org.apache.struts2.Unchainable; +import org.apache.struts2.result.Result; import org.apache.struts2.util.ValueStack; import java.util.ArrayList; diff --git a/core/src/main/java/org/apache/struts2/Result.java b/core/src/main/java/org/apache/struts2/result/Result.java similarity index 93% rename from core/src/main/java/org/apache/struts2/Result.java rename to core/src/main/java/org/apache/struts2/result/Result.java index 407994eabb..c30083d863 100644 --- a/core/src/main/java/org/apache/struts2/Result.java +++ b/core/src/main/java/org/apache/struts2/result/Result.java @@ -16,7 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.struts2; +package org.apache.struts2.result; + +import org.apache.struts2.Action; +import org.apache.struts2.ActionInvocation; import java.io.Serializable; diff --git a/core/src/test/java/com/opensymphony/xwork2/config/providers/ConfigurationProviderOgnlAllowlistTest.java b/core/src/test/java/com/opensymphony/xwork2/config/providers/ConfigurationProviderOgnlAllowlistTest.java index 51d2f96f27..6b31360a28 100644 --- a/core/src/test/java/com/opensymphony/xwork2/config/providers/ConfigurationProviderOgnlAllowlistTest.java +++ b/core/src/test/java/com/opensymphony/xwork2/config/providers/ConfigurationProviderOgnlAllowlistTest.java @@ -66,7 +66,7 @@ public void allowlist() throws Exception { Class.forName("com.opensymphony.xwork2.SimpleAction"), Class.forName("org.apache.struts2.interceptor.Interceptor"), Class.forName("org.apache.struts2.interceptor.ConditionalInterceptor"), - Class.forName("org.apache.struts2.Result"), + Class.forName("org.apache.struts2.result.Result"), Class.forName("org.apache.struts2.Action"), Class.forName("org.apache.struts2.Validateable"), Class.forName("org.apache.struts2.interceptor.ValidationAware") @@ -98,7 +98,7 @@ public void allowlist_1only() throws Exception { Class.forName("com.opensymphony.xwork2.SimpleAction"), Class.forName("org.apache.struts2.interceptor.Interceptor"), Class.forName("org.apache.struts2.interceptor.ConditionalInterceptor"), - Class.forName("org.apache.struts2.Result"), + Class.forName("org.apache.struts2.result.Result"), Class.forName("org.apache.struts2.Action"), Class.forName("org.apache.struts2.Validateable"), Class.forName("org.apache.struts2.interceptor.ValidationAware") @@ -129,7 +129,7 @@ public void allowlist_2only() throws Exception { Class.forName("com.opensymphony.xwork2.Result"), Class.forName("org.apache.struts2.interceptor.Interceptor"), Class.forName("org.apache.struts2.interceptor.ConditionalInterceptor"), - Class.forName("org.apache.struts2.Result"), + Class.forName("org.apache.struts2.result.Result"), Class.forName("org.apache.struts2.Action"), Class.forName("org.apache.struts2.Validateable"), Class.forName("org.apache.struts2.interceptor.ValidationAware")