struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject struts git commit: WW-4050 Converts NoSuchMethodExceotion into ConfigurationException
Date Mon, 02 Jan 2017 08:00:31 GMT
Repository: struts
Updated Branches:
  refs/heads/master 55fed5376 -> 97419283e


WW-4050 Converts NoSuchMethodExceotion into ConfigurationException


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/97419283
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/97419283
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/97419283

Branch: refs/heads/master
Commit: 97419283ea50efe2aa7f2a09e2b8f378a3fc0a4c
Parents: 55fed53
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Mon Jan 2 09:00:21 2017 +0100
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Mon Jan 2 09:00:21 2017 +0100

----------------------------------------------------------------------
 .../AnnotationValidationInterceptor.java        | 21 +++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/97419283/core/src/main/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
b/core/src/main/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
index 8344caa..572572e 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
@@ -22,10 +22,13 @@
 package org.apache.struts2.interceptor.validation;
 
 import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.config.ConfigurationException;
 import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.AnnotationUtils;
 import com.opensymphony.xwork2.validator.ValidationInterceptor;
 import org.apache.commons.lang3.BooleanUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 import org.apache.struts2.StrutsConstants;
 
 import java.lang.reflect.Method;
@@ -38,19 +41,20 @@ import java.util.Collection;
  */
 public class AnnotationValidationInterceptor extends ValidationInterceptor {
 
-    /** Auto-generated serialization id */
-    private static final long serialVersionUID = 1813272797367431184L;
+    private static final Logger LOG = LogManager.getLogger(AnnotationValidationInterceptor.class);
 
     protected String doIntercept(ActionInvocation invocation) throws Exception {
 
         Object action = invocation.getAction();
         if (action != null) {
             Method method = getActionMethod(action.getClass(), invocation.getProxy().getMethod());
+
             Collection<Method> annotatedMethods = AnnotationUtils.getAnnotatedMethods(action.getClass(),
SkipValidation.class);
-            if (annotatedMethods.contains(method))
+            if (annotatedMethods.contains(method)) {
                 return invocation.invoke();
+            }
 
-            //check if method overwites an annotated method
+            LOG.debug("Check if method overrides an annotated method");
             Class clazz = action.getClass().getSuperclass();
             while (clazz != null) {
                 annotatedMethods = AnnotationUtils.getAnnotatedMethods(clazz, SkipValidation.class);
@@ -69,9 +73,12 @@ public class AnnotationValidationInterceptor extends ValidationInterceptor
{
         return super.doIntercept(invocation);
     }
 
-    // FIXME: This is copied from DefaultActionInvocation but should be exposed through the
interface
-    protected Method getActionMethod(Class<?> actionClass, String methodName) throws
NoSuchMethodException {
-        return actionClass.getMethod(methodName);
+    protected Method getActionMethod(Class<?> actionClass, String methodName) {
+        try {
+            return actionClass.getMethod(methodName);
+        } catch (NoSuchMethodException e) {
+            throw new ConfigurationException("Wrong method was defined as an action method:
" + methodName, e);
+        }
     }
 
 }


Mime
View raw message