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

kusal pushed a commit to branch 7.0.x/merge-master-2024-11-01
in repository https://gitbox.apache.org/repos/asf/struts.git

commit a34bffdf355e6cd6daec0b3746a0a3ba839638e6
Merge: 56004a10a 243244997
Author: Kusal Kithul-Godage <g...@kusal.io>
AuthorDate: Fri Nov 1 15:38:54 2024 +1100

    Merge branch 'kusal-depr-apis-7' into 7.0.x/merge-master-2024-11-01
    
    # Conflicts:
    #       core/src/main/java/com/opensymphony/xwork2/ActionSupport.java
    #       
core/src/main/java/com/opensymphony/xwork2/interceptor/AbstractInterceptor.java
    #       
core/src/main/java/com/opensymphony/xwork2/interceptor/MethodFilterInterceptorUtil.java
    #       
core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java

 .../com/opensymphony/xwork2/ActionSupport.java     | 341 +--------------------
 .../xwork2/config/entities/InterceptorMapping.java |  10 +-
 .../xwork2/interceptor/AbstractInterceptor.java    |  35 +--
 .../xwork2/interceptor/AliasInterceptor.java       |   3 +
 .../xwork2/interceptor/ChainingInterceptor.java    |   3 +
 .../interceptor/ConversionErrorInterceptor.java    |   3 +
 .../interceptor/DefaultWorkflowInterceptor.java    |   3 +
 .../interceptor/ExceptionMappingInterceptor.java   |   3 +
 .../xwork2/interceptor/LoggingInterceptor.java     |   3 +
 .../interceptor/MethodFilterInterceptor.java       |  45 +--
 .../interceptor/MethodFilterInterceptorUtil.java   | 124 +-------
 .../xwork2/interceptor/ModelDrivenInterceptor.java |   3 +
 .../interceptor/ParameterRemoverInterceptor.java   |   3 +
 .../interceptor/PrefixMethodInvocationUtil.java    |   5 +-
 .../xwork2/interceptor/PrepareInterceptor.java     |   3 +
 .../interceptor/ScopedModelDrivenInterceptor.java  |   3 +
 .../interceptor/StaticParametersInterceptor.java   |   3 +
 .../apache/struts2}/ActionSupport.java             |  20 +-
 .../struts2}/interceptor/AbstractInterceptor.java  |   4 +-
 .../struts2}/interceptor/AliasInterceptor.java     |  17 +-
 .../struts2}/interceptor/ChainingInterceptor.java  |  14 +-
 .../interceptor/ConversionErrorInterceptor.java    |  24 +-
 .../interceptor/DefaultWorkflowInterceptor.java    |  19 +-
 .../interceptor/ExceptionMappingInterceptor.java   |  14 +-
 .../struts2}/interceptor/LoggingInterceptor.java   |   6 +-
 .../interceptor/MethodFilterInterceptor.java       |  50 +--
 .../interceptor/MethodFilterInterceptorUtil.java   |   8 +-
 .../interceptor/ModelDrivenInterceptor.java        |  15 +-
 .../interceptor/ParameterRemoverInterceptor.java   |   8 +-
 .../struts2}/interceptor/PrepareInterceptor.java   |  11 +-
 .../interceptor/ScopedModelDrivenInterceptor.java  |  16 +-
 .../interceptor/StaticParametersInterceptor.java   |  18 +-
 .../apache/struts2/result/StrutsResultSupport.java |  25 +-
 .../ConfigurationProviderOgnlAllowlistTest.java    |   6 +
 34 files changed, 230 insertions(+), 638 deletions(-)

diff --cc 
core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorMapping.java
index e90cd1014,6625bc7a1..1c0a9d01f
--- 
a/core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorMapping.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/config/entities/InterceptorMapping.java
@@@ -33,12 -32,20 +33,20 @@@ import java.util.Objects
   */
  public class InterceptorMapping implements Serializable {
  
 -    private String name;
 -    private Interceptor interceptor;
 +    private final String name;
 +    private final Interceptor interceptor;
      private final Map<String, String> params;
  
+     public InterceptorMapping(String name, 
org.apache.struts2.interceptor.Interceptor interceptor) {
+         this(name, Interceptor.adapt(interceptor));
+     }
+ 
+     public InterceptorMapping(String name, 
org.apache.struts2.interceptor.Interceptor interceptor, Map<String, String> 
params) {
+         this(name, Interceptor.adapt(interceptor), params);
+     }
+ 
      public InterceptorMapping(String name, Interceptor interceptor) {
-         this(name, interceptor, new HashMap<String, String>());
+         this(name, interceptor, new HashMap<>());
      }
  
      public InterceptorMapping(String name, Interceptor interceptor, 
Map<String, String> params) {
diff --cc 
core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java
index f3fd6fecd,d238e1ceb..b590ca4af
--- 
a/core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/interceptor/DefaultWorkflowInterceptor.java
@@@ -134,10 -132,12 +134,13 @@@ import java.io.Serial
   * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru 
Popescu</a>
   * @author Philip Luppens
   * @author tm_jee
+  *
+  * @deprecated since 6.7.0, use {@link 
org.apache.struts2.interceptor.DefaultWorkflowInterceptor} instead.
   */
+ @Deprecated
  public class DefaultWorkflowInterceptor extends MethodFilterInterceptor {
  
 +    @Serial
      private static final long serialVersionUID = 7563014655616490865L;
  
      private static final Logger LOG = 
LogManager.getLogger(DefaultWorkflowInterceptor.class);
diff --cc 
core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java
index b744ed1f6,0ac840c7a..40cea29a2
--- 
a/core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/interceptor/PrefixMethodInvocationUtil.java
@@@ -53,7 -58,7 +53,7 @@@ import java.lang.reflect.Method
   *    <li>else if the action class have prepareDo(MethodName()}(), it will be 
invoked</li>
   *    <li>no matter if 1] or 2] is performed, if alwaysinvokePrepare property 
of the interceptor is "true" (which is by default "true"), prepare() will be 
invoked.</li>
   * </ol>
-  * <p>
 - *
++ *<p>
   * <!-- END SNIPPET: javadocPrepareInterceptor -->
   *
   * @author Philip Luppens
@@@ -68,84 -73,86 +68,87 @@@ public class PrefixMethodInvocationUti
      private static final Class[] EMPTY_CLASS_ARRAY = new Class[0];
  
      /**
 -       * <p>
 -       * This method will prefix <code>actionInvocation</code>'s 
<code>ActionProxy</code>'s
 -       * <code>method</code> with <code>prefixes</code> before invoking the 
prefixed method.
 -       * Order of the <code>prefixes</code> is important, as this method will 
return once
 -       * a prefixed method is found in the action class.
 -       * </p>
 -       *
 -       * <p>
 -       * For example, with
 -       * </p>
 -       *
 -       * <pre>
 -       *   invokePrefixMethod(actionInvocation, new String[] { "prepare", 
"prepareDo" });
 -       * </pre>
 -       *
 -       * <p>
 -       * Assuming <code>actionInvocation.getProxy(),getMethod()</code> 
returns "submit",
 -       * the order of invocation would be as follows:-
 -       * </p>
 -       *
 -       * <ol>
 -       *   <li>prepareSubmit()</li>
 -       *   <li>prepareDoSubmit()</li>
 -       * </ol>
 -       *
 -       * <p>
 -       * If <code>prepareSubmit()</code> exists, it will be invoked and this 
method
 -       * will return, <code>prepareDoSubmit()</code> will NOT be invoked.
 -       * </p>
 -       *
 -       * <p>
 -       * On the other hand, if <code>prepareDoSubmit()</code> does not 
exists, and
 -       * <code>prepareDoSubmit()</code> exists, it will be invoked.
 -       * </p>
 -       *
 -       * <p>
 -       * If none of those two methods exists, nothing will be invoked.
 -       * </p>
 -       *
 -       * @param actionInvocation  the action invocation
 -       * @param prefixes  prefixes for method names
 -       * @throws InvocationTargetException is thrown if invocation of a 
method failed.
 -       * @throws IllegalAccessException  is thrown if invocation of a method 
failed.
 -       */
 -      public static void invokePrefixMethod(ActionInvocation 
actionInvocation, String[] prefixes) throws InvocationTargetException, 
IllegalAccessException {
 -              Object action = actionInvocation.getAction();
 +     * <p>
 +     * This method will prefix <code>actionInvocation</code>'s 
<code>ActionProxy</code>'s
 +     * <code>method</code> with <code>prefixes</code> before invoking the 
prefixed method.
 +     * Order of the <code>prefixes</code> is important, as this method will 
return once
 +     * a prefixed method is found in the action class.
 +     * </p>
 +     *
 +     * <p>
 +     * For example, with
 +     * </p>
 +     *
 +     * <pre>
 +     *   invokePrefixMethod(actionInvocation, new String[] { "prepare", 
"prepareDo" });
 +     * </pre>
 +     *
 +     * <p>
 +     * Assuming <code>actionInvocation.getProxy(),getMethod()</code> returns 
"submit",
 +     * the order of invocation would be as follows:-
 +     * </p>
 +     *
 +     * <ol>
 +     *   <li>prepareSubmit()</li>
 +     *   <li>prepareDoSubmit()</li>
 +     * </ol>
 +     *
 +     * <p>
 +     * If <code>prepareSubmit()</code> exists, it will be invoked and this 
method
 +     * will return, <code>prepareDoSubmit()</code> will NOT be invoked.
 +     * </p>
 +     *
 +     * <p>
 +     * On the other hand, if <code>prepareDoSubmit()</code> does not exists, 
and
 +     * <code>prepareDoSubmit()</code> exists, it will be invoked.
 +     * </p>
 +     *
 +     * <p>
 +     * If none of those two methods exists, nothing will be invoked.
 +     * </p>
 +     *
 +     * @param actionInvocation the action invocation
 +     * @param prefixes         prefixes for method names
 +     * @throws InvocationTargetException is thrown if invocation of a method 
failed.
 +     * @throws IllegalAccessException    is thrown if invocation of a method 
failed.
 +     */
 +    public static void invokePrefixMethod(ActionInvocation actionInvocation,
 +                                          String[] prefixes) throws 
InvocationTargetException, IllegalAccessException {
 +        Object action = actionInvocation.getAction();
  
 -              String methodName = actionInvocation.getProxy().getMethod();
 +        String methodName = actionInvocation.getProxy().getMethod();
  
 -              if (methodName == null) {
 -                      // if null returns (possible according to the docs), 
use the default execute
 -              methodName = DEFAULT_INVOCATION_METHODNAME;
 -              }
 +        if (methodName == null) {
 +            // if null returns (possible according to the docs), use the 
default execute
 +            methodName = DEFAULT_INVOCATION_METHODNAME;
 +        }
  
 -              Method method = getPrefixedMethod(prefixes, methodName, action);
 -              if (method != null) {
 -                      method.invoke(action, new Object[0]);
 -              }
 -      }
 +        Method method = getPrefixedMethod(prefixes, methodName, action);
 +        if (method != null) {
 +            method.invoke(action);
 +        }
 +    }
  
 -      public static void 
invokePrefixMethod(org.apache.struts2.ActionInvocation actionInvocation, 
String[] prefixes) throws InvocationTargetException, IllegalAccessException {
 -              invokePrefixMethod(ActionInvocation.adapt(actionInvocation), 
prefixes);
 -      }
++    public static void invokePrefixMethod(org.apache.struts2.ActionInvocation 
actionInvocation, String[] prefixes) throws InvocationTargetException, 
IllegalAccessException {
++        invokePrefixMethod(ActionInvocation.adapt(actionInvocation), 
prefixes);
++    }
  
 -      /**
 -       * This method returns a {@link Method} in <code>action</code>. The 
method
 -       * returned is found by searching for method in <code>action</code> 
whose method name
 -       * is equals to the result of appending each <code>prefixes</code>
 -       * to <code>methodName</code>. Only the first method found will be 
returned, hence
 -       * the order of <code>prefixes</code> is important. If none is found 
this method
 -       * will return null.
 -       *
 -       * @param prefixes the prefixes to prefix the <code>methodName</code>
 -       * @param methodName the method name to be prefixed with 
<code>prefixes</code>
 -       * @param action the action class of which the prefixed method is to be 
search for.
 -       * @return a {@link Method} if one is found, else <tt>null</tt>.
 -       */
 -      public static Method getPrefixedMethod(String[] prefixes, String 
methodName, Object action) {
 -              assert(prefixes != null);
 -              String capitalizedMethodName = capitalizeMethodName(methodName);
 +    /**
 +     * This method returns a {@link Method} in <code>action</code>. The method
 +     * returned is found by searching for method in <code>action</code> whose 
method name
 +     * is equals to the result of appending each <code>prefixes</code>
 +     * to <code>methodName</code>. Only the first method found will be 
returned, hence
 +     * the order of <code>prefixes</code> is important. If none is found this 
method
 +     * will return null.
 +     *
 +     * @param prefixes   the prefixes to prefix the <code>methodName</code>
 +     * @param methodName the method name to be prefixed with 
<code>prefixes</code>
 +     * @param action     the action class of which the prefixed method is to 
be search for.
 +     * @return a {@link Method} if one is found, else <tt>null</tt>.
 +     */
 +    public static Method getPrefixedMethod(String[] prefixes, String 
methodName, Object action) {
 +        assert (prefixes != null);
 +        String capitalizedMethodName = capitalizeMethodName(methodName);
          for (String prefix : prefixes) {
              String prefixedMethodName = prefix + capitalizedMethodName;
              try {
diff --cc 
core/src/main/java/com/opensymphony/xwork2/interceptor/PrepareInterceptor.java
index efaeb4a61,43bb12c2b..e617ec2b5
--- 
a/core/src/main/java/com/opensymphony/xwork2/interceptor/PrepareInterceptor.java
+++ 
b/core/src/main/java/com/opensymphony/xwork2/interceptor/PrepareInterceptor.java
@@@ -97,10 -96,12 +97,13 @@@ import java.lang.reflect.InvocationTarg
   * @author Philip Luppens
   * @author tm_jee
   * @see com.opensymphony.xwork2.Preparable
+  *
+  * @deprecated since 6.7.0, use {@link 
org.apache.struts2.interceptor.PrepareInterceptor} instead.
   */
+ @Deprecated
  public class PrepareInterceptor extends MethodFilterInterceptor {
  
 +    @Serial
      private static final long serialVersionUID = -5216969014510719786L;
  
      private final static String PREPARE_PREFIX = "prepare";
diff --cc core/src/main/java/org/apache/struts2/ActionSupport.java
index 33a88be36,04c513f3a..22d22a66c
--- a/core/src/main/java/org/apache/struts2/ActionSupport.java
+++ b/core/src/main/java/org/apache/struts2/ActionSupport.java
@@@ -24,10 -29,10 +29,9 @@@ import com.opensymphony.xwork2.inject.I
  import com.opensymphony.xwork2.util.ValueStack;
  import org.apache.logging.log4j.LogManager;
  import org.apache.logging.log4j.Logger;
- import org.apache.struts2.StrutsConstants;
+ import org.apache.struts2.interceptor.ValidationAware;
  
  import java.io.Serializable;
 -import java.util.Arrays;
  import java.util.Collection;
  import java.util.List;
  import java.util.Locale;
@@@ -162,9 -167,9 +166,9 @@@ public class ActionSupport implements A
              String[] vals = (String[]) conversionErrors.get(expr).getValue();
              return vals[0];
          } else {
-             final ValueStack valueStack = 
ActionContext.getContext().getValueStack();
 -            final ValueStack valueStack = 
ValueStack.adapt(ActionContext.getContext().getValueStack());
++            var valueStack = ActionContext.getContext().getValueStack();
              final Object val = valueStack.findValue(expr);
 -            return getText(key, Arrays.asList(val));
 +            return getText(key, List.of(val));
          }
      }
  
diff --cc 
core/src/main/java/org/apache/struts2/interceptor/MethodFilterInterceptorUtil.java
index ac5acee65,2a43ba2ff..065305343
--- 
a/core/src/main/java/org/apache/struts2/interceptor/MethodFilterInterceptorUtil.java
+++ 
b/core/src/main/java/org/apache/struts2/interceptor/MethodFilterInterceptorUtil.java
@@@ -24,11 -24,9 +24,11 @@@ import com.opensymphony.xwork2.util.Wil
  import java.util.HashMap;
  import java.util.Set;
  
 +import static java.util.Objects.requireNonNullElse;
 +
  /**
   * Utility class contains common methods used by
-  * {@link com.opensymphony.xwork2.interceptor.MethodFilterInterceptor}.
+  * {@link MethodFilterInterceptor}.
   *
   * @author tm_jee
   */
@@@ -79,9 -79,13 +79,7 @@@ public class MethodFilterInterceptorUti
  
          // test the methods using pattern matching
          WildcardHelper wildcard = new WildcardHelper();
--        String methodCopy ;
-         // no method specified
-         methodCopy = requireNonNullElse(method, "");
 -        if (method == null ) { // no method specified
 -            methodCopy = "";
 -        }
 -        else {
 -            methodCopy = new String(method);
 -        }
++        String methodCopy = requireNonNullElse(method, "");
          for (String pattern : includeMethods) {
              if (pattern.contains("*")) {
                  int[] compiledPattern = wildcard.compilePattern(pattern);

Reply via email to