Uploaded image for project: 'Struts 2'
  1. Struts 2
  2. WW-4050

AnnotationValidationInterceptor should consult UnknownHandler before throwing NoSuchMethodException

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3.14
    • Fix Version/s: 2.5.10
    • Component/s: None
    • Labels:
      None

      Description

      If a NoSuchMethodException is caught when invoking getActionMethod(), AnnotationValidationInterceptor should first give any configured UnknownHandler a shot, before throwing the exception directly, just as what DefaultActionInvocation.invokeAction() does.

      Any unknown Action or unknown Result is currently handled by Dispatcher.serviceAction(), and a 404 error code will be returned as expected. But an unknown Method will raise a 500 error, the only way to avoid this is to configure an UnknownHandler. Therefore, AnnotationValidationInterceptor won't inspect UnknownHandler at all...

      GET /foo/list  404 (Action "foo" not found)
      GET /bar/list  200
      GET /bar/print 500 (Method "print" not found, 404 is expected instead of 500)

        Issue Links

          Activity

          Hide
          lukaszlenart Lukasz Lenart added a comment -

          Could you prepare a small Maven based demo app?

          Show
          lukaszlenart Lukasz Lenart added a comment - Could you prepare a small Maven based demo app?
          Hide
          lukaszlenart Lukasz Lenart added a comment -

          It isn't possible to use UnknownHandler here as it will try to execute method which can have a side effects. Instead, I've converted NoSuchMethodException into ConfigurationException which then is handled by Dispatcher and effects in 404

          Show
          lukaszlenart Lukasz Lenart added a comment - It isn't possible to use UnknownHandler here as it will try to execute method which can have a side effects. Instead, I've converted NoSuchMethodException into ConfigurationException which then is handled by Dispatcher and effects in 404
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 97419283ea50efe2aa7f2a09e2b8f378a3fc0a4c in struts's branch refs/heads/master from Lukasz Lenart
          [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=9741928 ]

          WW-4050 Converts NoSuchMethodExceotion into ConfigurationException

          Show
          jira-bot ASF subversion and git services added a comment - Commit 97419283ea50efe2aa7f2a09e2b8f378a3fc0a4c in struts's branch refs/heads/master from Lukasz Lenart [ https://git-wip-us.apache.org/repos/asf?p=struts.git;h=9741928 ] WW-4050 Converts NoSuchMethodExceotion into ConfigurationException
          Hide
          hudson Hudson added a comment -

          SUCCESS: Integrated in Jenkins build Struts-JDK7-master #577 (See https://builds.apache.org/job/Struts-JDK7-master/577/)
          WW-4050 Converts NoSuchMethodExceotion into ConfigurationException (lukaszlenart: rev 97419283ea50efe2aa7f2a09e2b8f378a3fc0a4c)

          • (edit) core/src/main/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java
          Show
          hudson Hudson added a comment - SUCCESS: Integrated in Jenkins build Struts-JDK7-master #577 (See https://builds.apache.org/job/Struts-JDK7-master/577/ ) WW-4050 Converts NoSuchMethodExceotion into ConfigurationException (lukaszlenart: rev 97419283ea50efe2aa7f2a09e2b8f378a3fc0a4c) (edit) core/src/main/java/org/apache/struts2/interceptor/validation/AnnotationValidationInterceptor.java

            People

            • Assignee:
              lukaszlenart Lukasz Lenart
              Reporter:
              azuo_lee Azuo Lee
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development