Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-287

Clarify the order of CDI interceptors wrt. around-invoke method of target class

XMLWordPrintable

    • Icon: Clarification Clarification
    • Resolution: Done
    • Icon: Major Major
    • 1.1.PFD
    • 1.0
    • Interceptors
    • None

      Currently, the CDI specification doesn't define, when is the around-invoke method of a target class called, with regard to CDI interceptors.

      The spec. only says, in 9.4, towards the end:

      Interceptors declared using @Interceptors or in ejb-jar.xml are called before interceptors declared using interceptor bindings.

      Currently, the order happens to be (in EAP6):

      1. @Interceptors and ejb-jar.xml
      2. Around-invoke method
      3. CDI interceptors

      In the following example the order of interception would be:

      1. FirstInterceptor
      2. SomeClass.aroundInvoke
      3. ThirdInterceptor

        public class SomeClass {
          @ThirdInterceptorBinding // bound to ThirdInterceptor
          @Interceptors(FirstInterceptor.class)
          public int doSomething() {
            // ...
          }
        
          @AroundInvoke // comes second
          public Object aroundInvoke(InvocationContext invocationContext) throws Exception {
            return invocationContext.proceed();
          }
        }
        

      This problem manifests in this (currently skipped) test:
      https://github.com/weld/core/blob/1.1/tests-arquillian/src/test/java/org/jboss/weld/tests/interceptors/retry/RetryInterceptorTest.java

            pmuiratbleepbleep Pete Muir (Inactive)
            rsmeral Ron Šmeral (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: