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-4439 Drops support for do prefix in methods
Date Sun, 21 Jun 2015 09:37:38 GMT
Repository: struts
Updated Branches:
  refs/heads/master 356b5c57b -> 586f770d3


WW-4439 Drops support for do prefix in methods


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

Branch: refs/heads/master
Commit: 586f770d3072f668a1092e83a2f6ac47f7a713e1
Parents: 356b5c5
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Sun Jun 21 11:37:28 2015 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Sun Jun 21 11:37:28 2015 +0200

----------------------------------------------------------------------
 .../xwork2/DefaultActionInvocation.java         | 39 ++++-------
 .../AnnotationValidationInterceptor.java        | 27 +-------
 .../xwork2/DefaultActionInvocationTest.java     | 73 +-------------------
 .../com/opensymphony/xwork2/SimpleAction.java   |  8 ---
 .../interceptor/BeanValidationInterceptor.java  | 14 +---
 .../BeanValidationInterceptorTest.java          | 13 ----
 6 files changed, 19 insertions(+), 155 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/586f770d/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
index 82c0eec..da9fce6 100644
--- a/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
+++ b/core/src/main/java/com/opensymphony/xwork2/DefaultActionInvocation.java
@@ -414,33 +414,22 @@ public class DefaultActionInvocation implements ActionInvocation {
             try {
                 methodResult = ognlUtil.getValue(methodName + "()", getStack().getContext(),
action);
             } catch (MethodFailedException e) {
-                // if reason is missing method, try find version with "do" prefix
+                // if reason is missing method,  try checking UnknownHandlers
                 if (e.getReason() instanceof NoSuchMethodException) {
-                    try {
-                        String altMethodName = "do" + methodName.substring(0, 1).toUpperCase()
+ methodName.substring(1) + "()";
-                        methodResult = ognlUtil.getValue(altMethodName, getStack().getContext(),
action);
-                    } catch (MethodFailedException e1) {
-                        // if still method doesn't exist, try checking UnknownHandlers
-                        if (e1.getReason() instanceof NoSuchMethodException) {
-                            if (unknownHandlerManager.hasUnknownHandlers()) {
-                                try {
-                                    methodResult = unknownHandlerManager.handleUnknownMethod(action,
methodName);
-                                } catch (NoSuchMethodException e2) {
-                                    // throw the original one
-                                    throw e;
-                                }
-                            } else {
-                                // throw the original one
-                                throw e;
-                            }
-                            // throw the original exception as UnknownHandlers weren't able
to handle invocation as well
-                            if (methodResult == null) {
-                                throw e;
-                            }
-                        } else {
-                            // exception isn't related to missing action method, throw it
-                            throw e1;
+                    if (unknownHandlerManager.hasUnknownHandlers()) {
+                        try {
+                            methodResult = unknownHandlerManager.handleUnknownMethod(action,
methodName);
+                        } catch (NoSuchMethodException ignore) {
+                            // throw the original one
+                            throw e;
                         }
+                    } else {
+                        // throw the original one
+                        throw e;
+                    }
+                    // throw the original exception as UnknownHandlers weren't able to handle
invocation as well
+                    if (methodResult == null) {
+                        throw e;
                     }
                 } else {
                     // exception isn't related to missing action method, throw it

http://git-wip-us.apache.org/repos/asf/struts/blob/586f770d/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 ddc8bbb..8344caa 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
@@ -41,13 +41,6 @@ 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 = BooleanUtils.toBoolean(devMode);
-    }
-
     protected String doIntercept(ActionInvocation invocation) throws Exception {
 
         Object action = invocation.getAction();
@@ -77,24 +70,8 @@ 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 = null;
-        Class[] classes = new Class[0];
-        try {
-            method = actionClass.getMethod(methodName, classes);
-        } catch (NoSuchMethodException e) {
-            // hmm -- OK, try doXxx instead
-            try {
-                String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() +
methodName.substring(1);
-                method = actionClass.getMethod(altMethodName, classes);
-            } catch (NoSuchMethodException e1) {
-                // throw the original one
-                if (devMode) {
-                    throw e;
-                }
-            }
-        }
-        return method;
+    protected Method getActionMethod(Class<?> actionClass, String methodName) throws
NoSuchMethodException {
+        return actionClass.getMethod(methodName);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/struts/blob/586f770d/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java b/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
index 23e1904..b535067 100644
--- a/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
+++ b/core/src/test/java/com/opensymphony/xwork2/DefaultActionInvocationTest.java
@@ -106,28 +106,6 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
         assertEquals("success", result);
     }
 
-    public void testInvokingExistingDoInputMethod() throws Exception {
-        // given
-        DefaultActionInvocation dai = new DefaultActionInvocation(new HashMap<String,
Object>(), false) {
-            public ValueStack getStack() {
-                return new StubValueStack();
-            }
-        };
-
-        SimpleAction action = new SimpleAction();
-        MockActionProxy proxy = new MockActionProxy();
-        proxy.setMethod("with");
-
-        dai.proxy = proxy;
-        dai.ognlUtil = new OgnlUtil();
-
-        // when
-        String result = dai.invokeAction(action, null);
-
-        // then
-        assertEquals("with", result);
-    }
-
     public void testInvokingMissingMethod() throws Exception {
         // given
         DefaultActionInvocation dai = new DefaultActionInvocation(new HashMap<String,
Object>(), false) {
@@ -202,48 +180,6 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
         assertTrue(actual instanceof IllegalArgumentException);
     }
 
-    public void testInvokingExistingDoMethodThatThrowsException() throws Exception {
-        // given
-        DefaultActionInvocation dai = new DefaultActionInvocation(new HashMap<String,
Object>(), false) {
-            public ValueStack getStack() {
-                return new StubValueStack();
-            }
-        };
-
-        UnknownHandlerManager uhm = new DefaultUnknownHandlerManager() {
-            @Override
-            public boolean hasUnknownHandlers() {
-                return false;
-            }
-        };
-
-        SimpleAction action = new SimpleAction() {
-            @Override
-            public String doWith() throws Exception {
-                throw new IllegalArgumentException();
-            }
-        };
-        MockActionProxy proxy = new MockActionProxy();
-        proxy.setMethod("with");
-
-        dai.proxy = proxy;
-        dai.ognlUtil = new OgnlUtil();
-        dai.unknownHandlerManager = uhm;
-
-        // when
-        // when
-        Throwable actual = null;
-        try {
-            dai.invokeAction(action, null);
-        } catch (Exception e) {
-            actual = e;
-        }
-
-        // then
-        assertNotNull(actual);
-        assertTrue(actual instanceof IllegalArgumentException);
-    }
-
     @Deprecated
     public void testUnknownHandlerManagerThatThrowsException() throws Exception {
         // given
@@ -265,12 +201,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
             }
         };
 
-        SimpleAction action = new SimpleAction() {
-            @Override
-            public String doWith() throws Exception {
-                throw new IllegalArgumentException();
-            }
-        };
+        SimpleAction action = new SimpleAction();
         MockActionProxy proxy = new MockActionProxy();
         proxy.setMethod("notExists");
 
@@ -315,7 +246,7 @@ public class DefaultActionInvocationTest extends XWorkTestCase {
 
         SimpleAction action = new SimpleAction() {
             @Override
-            public String doWith() throws Exception {
+            public String execute() throws Exception {
                 throw new IllegalArgumentException();
             }
         };

http://git-wip-us.apache.org/repos/asf/struts/blob/586f770d/core/src/test/java/com/opensymphony/xwork2/SimpleAction.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/com/opensymphony/xwork2/SimpleAction.java b/core/src/test/java/com/opensymphony/xwork2/SimpleAction.java
index d563ebf..7f9bb7a 100644
--- a/core/src/test/java/com/opensymphony/xwork2/SimpleAction.java
+++ b/core/src/test/java/com/opensymphony/xwork2/SimpleAction.java
@@ -243,14 +243,6 @@ public class SimpleAction extends ActionSupport {
         return SUCCESS;
     }
     
-    public String doInput() throws Exception {
-        return INPUT;
-    }
-
-    public String doWith() throws Exception {
-        return "with";
-    }
-
     public long getLongFoo() {
         return longFoo;
     }

http://git-wip-us.apache.org/repos/asf/struts/blob/586f770d/plugins/bean-validation/src/main/java/org/apache/struts/beanvalidation/validation/interceptor/BeanValidationInterceptor.java
----------------------------------------------------------------------
diff --git a/plugins/bean-validation/src/main/java/org/apache/struts/beanvalidation/validation/interceptor/BeanValidationInterceptor.java
b/plugins/bean-validation/src/main/java/org/apache/struts/beanvalidation/validation/interceptor/BeanValidationInterceptor.java
index 47ad6f3..aaed47d 100644
--- a/plugins/bean-validation/src/main/java/org/apache/struts/beanvalidation/validation/interceptor/BeanValidationInterceptor.java
+++ b/plugins/bean-validation/src/main/java/org/apache/struts/beanvalidation/validation/interceptor/BeanValidationInterceptor.java
@@ -177,19 +177,7 @@ public class BeanValidationInterceptor extends MethodFilterInterceptor
{
     protected Method getActionMethod(Class<?> actionClass, String methodName) throws
NoSuchMethodException {
         Method method;
 
-        try {
-            method = actionClass.getMethod(methodName, new Class[0]);
-        } catch (NoSuchMethodException e) {
-            // hmm -- OK, try doXxx instead
-            try {
-                String altMethodName = "do" + methodName.substring(0, 1).toUpperCase() +
-                        methodName.substring(1);
-                method = actionClass.getMethod(altMethodName, new Class[0]);
-            } catch (NoSuchMethodException e1) {
-                // throw the original one
-                throw e;
-            }
-        }
+        method = actionClass.getMethod(methodName);
 
         return method;
     }

http://git-wip-us.apache.org/repos/asf/struts/blob/586f770d/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
----------------------------------------------------------------------
diff --git a/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
b/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
index 7571aa7..5db0b36 100644
--- a/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
+++ b/plugins/bean-validation/src/test/java/org/apache/struts/beanvalidation/BeanValidationInterceptorTest.java
@@ -135,19 +135,6 @@ public class BeanValidationInterceptorTest extends XWorkTestCase {
         assertEquals(2, actionErrors.size());
     }
 
-    public void testFieldActionDoExecute() throws Exception {
-        ActionProxy baseActionProxy = actionProxyFactory.createActionProxy("bean-validation",
"fieldActionDoExecute", null, null);
-        FieldActionDoExecute action = (FieldActionDoExecute) baseActionProxy.getAction();
-        action.setTest(" ");
-        baseActionProxy.execute();
-
-        Map<String, List<String>> fieldErrors = ((ValidationAware) baseActionProxy.getAction()).getFieldErrors();
-
-        assertNotNull(fieldErrors);
-        assertEquals(1, fieldErrors.size());
-        assertTrue(fieldErrors.get("test").size() > 0);
-    }
-
     @Override
     protected void setUp() throws Exception {
         super.setUp();


Mime
View raw message