Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1225

Incorrect handling of overridden callback methods for lifecycle events

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 1.1.5.Final, 2.0.0.Alpha3
    • Fix Version/s: 1.1.14.Final, 2.0.0.Beta1
    • Component/s: None
    • Labels:
      None

      Description

      Weld does not follow the Interceptors spec. See also "Multiple Callback Interceptor Methods for a Life Cycle Callback Event" chapter:

      • ...
      • If a lifecycle callback interceptor method is overridden by another method (regardless of whether that method is itself a lifecycle callback interceptor method (of the same or different type)), it will not be invoked.
      • ...

      Check the following use cases:

      class Bar {
        @PostConstruct
        public void init() {
        }
      }
      class Foo extends Bar {
        @PostConstruct // Overrides Bar#init()
        public void init() {
        }
      }
      

      -> Bar#init() should not be invoked, but Foo#init() is invoked twice!

      class Bar {
        @PostConstruct
        public void init() {
        }
      }
      class Foo extends Bar {
        // Overrides Bar#init()  
        public void init() {
        }
      }
      

      -> Neither one of init() methods should be invoked, but Foo#init() is invoked!

      Right now there is no CDI TCK test for this - I will probably provide some as soon as I get familiar with the relationship of concerned specs.

      Thanks to JJ Snyder for reporting the issue.

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            mkouba Martin Kouba added a comment -

            Hint: Beans.getPostConstructMethods(EnhancedAnnotatedType<T>) should probably filter out overriden callback methods.

            Show
            mkouba Martin Kouba added a comment - Hint: Beans.getPostConstructMethods(EnhancedAnnotatedType<T>) should probably filter out overriden callback methods.
            Hide
            mkouba Martin Kouba added a comment -

            And of course the same applies to Beans.getPreDestroyMethods(EnhancedAnnotatedType<T>).

            Show
            mkouba Martin Kouba added a comment - And of course the same applies to Beans.getPreDestroyMethods(EnhancedAnnotatedType<T>).
            Hide
            mkouba Martin Kouba added a comment -

            Added TCK Interceptors integration test:
            org.jboss.cdi.tck.interceptors.tests.lifecycleCallback.overriden.OverridenLifecycleCallbackInterceptorTest

            Show
            mkouba Martin Kouba added a comment - Added TCK Interceptors integration test: org.jboss.cdi.tck.interceptors.tests.lifecycleCallback.overriden.OverridenLifecycleCallbackInterceptorTest
            Hide
            jharting Jozef Hartinger added a comment -

            Done. The logic that obtains methods of a specific type of a bean (e.g. lifecycle event callbacks, initializers and observers) was unified.

            Show
            jharting Jozef Hartinger added a comment - Done. The logic that obtains methods of a specific type of a bean (e.g. lifecycle event callbacks, initializers and observers) was unified.

              People

              • Assignee:
                jharting Jozef Hartinger
                Reporter:
                mkouba Martin Kouba
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Development