struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [1/2] git commit: WW-3134 Reduces noise in the logs
Date Wed, 09 Jul 2014 19:17:10 GMT
Repository: struts
Updated Branches:
  refs/heads/develop 2da93000d -> ecab1b2b8


WW-3134 Reduces noise in the logs


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

Branch: refs/heads/develop
Commit: 29bb41db3cc7364c82e01cf9bbf206e50ddb9c46
Parents: 2da9300
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Wed Jul 9 21:14:24 2014 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Wed Jul 9 21:14:24 2014 +0200

----------------------------------------------------------------------
 .../AnnotationValidationInterceptor.java         | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/29bb41db/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 232d6ff..01e8a41 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
@@ -25,12 +25,13 @@ import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collection;
 
-import org.apache.commons.lang3.ArrayUtils;
-
 import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.inject.Inject;
 import com.opensymphony.xwork2.util.AnnotationUtils;
 import com.opensymphony.xwork2.validator.ValidationInterceptor;
 
+import org.apache.struts2.StrutsConstants;
+
 /**
  * Extends the xwork validation interceptor to also check for a @SkipValidation
  * annotation, and if found, don't validate this action method
@@ -40,6 +41,13 @@ public class AnnotationValidationInterceptor extends ValidationInterceptor
{
     /** Auto-generated serialization id */
     private static final long serialVersionUID = 1813272797367431184L;
 
+    private boolean devMode;
+
+    @Inject(StrutsConstants.STRUTS_DEVMODE)
+    public void setDevMode(String devMode) {
+        this.devMode = "true".equalsIgnoreCase(devMode);
+    }
+
     protected String doIntercept(ActionInvocation invocation) throws Exception {
 
         Object action = invocation.getAction();
@@ -70,7 +78,7 @@ public class AnnotationValidationInterceptor extends ValidationInterceptor
{
 
     // FIXME: This is copied from DefaultActionInvocation but should be exposed through the
interface
     protected Method getActionMethod(Class actionClass, String methodName) throws NoSuchMethodException
{
-        Method method;
+        Method method = null;
         try {
             method = actionClass.getMethod(methodName, new Class[0]);
         } catch (NoSuchMethodException e) {
@@ -80,9 +88,12 @@ public class AnnotationValidationInterceptor extends ValidationInterceptor
{
                 method = actionClass.getMethod(altMethodName, new Class[0]);
             } catch (NoSuchMethodException e1) {
                 // throw the original one
-                throw e;
+                if (devMode) {
+                    throw e;
+                }
             }
         }
         return method;
     }
+
 }


Mime
View raw message