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

Interceptors not invoked when EJB local interface extends a generic interface


      According to WELD-568 bridge methods for covariant return types should not be intercepted.

      However, bridge methods that have a different signature, e.g. by using generics, should be interceptable.

      Consider the following case using generic EJB methods:

      //base definitions
      public class BaseParam {}
      public interface BaseInterface<T extends BaseParam> {
         public void doSomething( T param);
      //extension and ejb
      public class SpecialParam extends BaseParam{}
      public interface SpecialService extends BaseInterface<SpecialParam> {}
      public class SpecialServiceImpl implements SpecialService {
         public void doSomething( SpecialParam param) {}
      //call in another EJB
      private SpecialService s;
      s.doSomething(new SpecialParam());

      For this call the invocation context contains the method signature "SpecialServiceImpl.doSomething(BaseParam)" which is the bridge method generated due to the generic parameter.

      However, the method "Beans.getInterceptableMethods(WeldClass)" ignores this method when registering the interceptor because it is a bridge method:

      boolean businessMethod = !annotatedMethod.isStatic()
        && !annotatedMethod.isAnnotationPresent(Inject.class)
        && !annotatedMethod.getJavaMember().isBridge();

      Due to this, calls to bridge methods within EJBs are not intercepted.

      Possible solution:

      Bridge methods are not ignored by default but are replaced by non-bridge methods having the same signature when the interceptable methods are collected. That should solve this issue as well as WELD-568.

            marko.luksa@gmail.com Marko Luksa (Inactive)
            thomasgo_jira Thomas Goettlich (Inactive)
            1 Vote for this issue
            4 Start watching this issue