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

Decorator that only overrides a method with default implementation not called when calling said method on the decorated bean.

    XMLWordPrintable

    Details

    • Steps to Reproduce:
      Hide

      Create an interface with at least one method with a default implementation. Create a bean as implementing said interface that does not override the method with the default implementation. (All other methods are free for the taking.)
      Create an abstract decorator for the interface that only overrides (decorates) the method with the default implementation.
      Inject the bean, whether by interface or by concrete class, and call the method with the default implementation on it. You'll see that it does not get called.

      Show
      Create an interface with at least one method with a default implementation. Create a bean as implementing said interface that does not override the method with the default implementation. (All other methods are free for the taking.) Create an abstract decorator for the interface that only overrides (decorates) the method with the default implementation. Inject the bean, whether by interface or by concrete class, and call the method with the default implementation on it. You'll see that it does not get called.

      Description

      If a decorator overrides, among others, a method from the decorated interface which has no override in the actual bean class, a call to that method gets decorated.

      However, if you create an abstract decorator which only overrides (decorates) a method from the interface with a default implementation and no override in the actual bean class, the calls to that method do not get decorated.
      Expected behaviour would be that calls to decorated methods always get decorated, whether or not they have a default implementation and how many methods actually get overridden in the decorator.

      See the attached test case, which is a modification of the already existing DecoratedInteraceWithDefaultMethodTest.

      Note:
      It looks like the decorator does not get picked up if it does not decorate any business method which has an impl in the actual bean class. If it does override such a method, the calls to the default method do get intercepted. It does not matter whether the actual bean class overrides the method with a default impl or not, as long as the decorator overrides at least one method which has an impl in the bean class it works as intended.
      I'm unsure if it makes a difference to have an impl in an abstract superclass of the concrete bean class.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                manovotn Matej Novotny
                Reporter:
                buurmansven S Haster
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: