interceptors-spec
  1. interceptors-spec
  2. INTERCEPTORS_SPEC-8

Fix or explain throws Exception clause in interceptor method signatures

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.2
    • Labels:
      None

      Description

      WHAT's WRONG?
      The interceptors spec contradicts itself when describing an interceptor method exceptions rules and defining the interceptor method:

      A. The Interceptors spec restrictions on exceptions that can be thrown by an interceptor method:

      2.4Exceptions
      "Interceptor methods are allowed to throw runtime exceptions or any checked exceptions that the associated target method allows within its throws clause.
      Interceptor methods are allowed to catch and suppress exceptions and to recover by calling the theInvocationContext.proceed method."

      B. The EJB spec requirements on the timeout method:
      13.2.5.3Timeout Callback Method Requirements

      void <METHOD>()
      void <METHOD>(Timer timer)

      "Timeout callback methods must not throw application exceptions."

      C. The interceptor spec requirements on around-invoke and around-timeout method signatures

      2.5Business Method Interceptors

      Object <METHOD>(InvocationContext) throws Exception

      2.7Timeout Method Interceptors

      Object <METHOD>(InvocationContext) throws Exception

      ============

      As you can see, not only the around-timeout returns a value that the method it interposes on doesn't, but it also must declare the "throws Exception" clause while the target instance method can only throw RuntimeException's.

      The around-invoke requirement to declare "throws Exception" does not allow to be more specific.
      =============

      PROPOSED CHANGES

      There are 2 ways to fix the problem. Unless I hear an overwhelming support for #1, and overwhelming rejection of both options (#3), I'll go with option #2 to reduce the amount of changes in this version of the Interceptors spec.

      #1

      • Change method signatures for both around-invoke to make throws clause optional:
        Object <METHOD>(InvocationContext) [throws Exception]
      • Add a note to for the above:
        "An around-invoke interceptor method may declare to throw any checked exceptions that the associated target method allows within its throws clause. It may declare to throw a java.lang.Exception if it interposes on several methods that can throw unrelated checked exception."
      • Remove "throws Exception" clause from the around-timeout method

      #2

      • Add a note under the around-invoke method signature:
        "An around-invoke interceptor method may declare to throw any checked exceptions that the associated target method allows within its throws clause. It may declare to throw the java.lang.Exception if it interposes on several methods that can throw unrelated checked exception."
      • Add a note under the around-timeout method signature:
        "An around-timeout interceptor method must not throw application exceptions, but it may declare to throw checked exceptions or the java.lang.Exception if the same interceptor method interposes on business methods in addition to the timeout methods."

      #3
      The proposed changes do not make any sense

        Activity

        Hide
        marina vatkina added a comment -

        Added notes as described in #2

        Show
        marina vatkina added a comment - Added notes as described in #2

          People

          • Assignee:
            marina vatkina
            Reporter:
            marina vatkina
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: