mirror of
https://github.com/apache/struts.git
synced 2026-08-11 01:27:14 +00:00
WW-3134 Reduces noise in the logs
This commit is contained in:
+15
-4
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user