Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-1040

Lifecycle events fired during bean discovery do not follow specification sequence

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.5.0
    • 1.6.0
    • Lifecycle
    • None

    Description

      The lifecycle events, like ProcessInjectionPoint and ProcessBeanAttributes are not fired according to the sequence specified in the Bean discovery section of the specification.

      Besides, the BeanAttributes set with the ProcessBeanAttributes event are accessed directly which contradicts the ProcessBeanAttributes event specification:

      Any observer of this event is permitted to wrap and/or replace the BeanAttributes. The container must use the final value of this property, after all observers have been called, to manage instances of the bean. Changes to BeanAttributes are not propagated to the annotated type from which the bean definition was created.

      Failing test can be found here:
      https://github.com/astefanutti/camel-cdi/blob/a9e94607beaee546f76b7f6e70b9652bf8468d77/envs/se/src/test/java/org/apache/camel/cdi/se/EventEndpointTest.java

      The following exception is thrown when executed with OWB (not systematically though maybe due to multi-threading):

      org.apache.webbeans.exception.WebBeansDeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Api type [org.apache.camel.cdi.CdiEventEndpoint] is not found with the qualifiers
      Qualifiers: [@org.apache.camel.cdi.se.qualifier.BarQualifier()]
      for injection into Field Injection Point, field name :  barQualifierCdiEventEndpoint, Bean Owner : [EventConsumingRoute, WebBeansType:MANAGED, Name:null, API Types:[org.apache.camel.builder.RouteBuilder,org.apache.camel.builder.BuilderSupport,org.apache.camel.cdi.se.bean.EventConsumingRoute,java.lang.Object,org.apache.camel.RoutesBuilder], Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]]
      

      This is not supposed to happen as the missing qualifiers are dynamically added in the Camel CDI extension here: https://github.com/astefanutti/camel-cdi/blob/a9e94607beaee546f76b7f6e70b9652bf8468d77/impl/src/main/java/org/apache/camel/cdi/CdiCamelExtension.java#L118.

      The problem is that OWB calls the observer methods in a different sequence than expected:

      ProcessBeanAttributes<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessBeanAttributes<?>:class org.apache.camel.cdi.se.EventEndpointTest$EventObserver
      ProcessBeanAttributes<?>:class org.apache.camel.cdi.CdiCamelFactory$1
      ProcessBeanAttributes<?>:class org.apache.camel.cdi.CdiEventComponent
      ProcessBeanAttributes<?>:class org.apache.camel.cdi.se.bean.EventConsumingRoute
      ProcessBeanAttributes<?>:class org.apache.camel.cdi.se.EventEndpointTest
      ProcessBeanAttributes<?>:class org.apache.camel.cdi.CdiCamelFactory
      ProcessBeanAttributes<?>:interface org.apache.camel.Endpoint
      ProcessBeanAttributes<T>:interface org.apache.camel.Endpoint
      BeanAttributes.getQualifiers()
      ProcessBeanAttributes<?>:class org.apache.camel.component.mock.MockEndpoint
      ProcessBeanAttributes<T>:class org.apache.camel.component.mock.MockEndpoint
      BeanAttributes.getQualifiers()
      ProcessBeanAttributes<?>:class org.apache.camel.component.mock.MockEndpoint
      ProcessBeanAttributes<T>:class org.apache.camel.component.mock.MockEndpoint
      BeanAttributes.getQualifiers()
      ProcessBeanAttributes<?>:class org.apache.camel.component.mock.MockEndpoint
      ProcessBeanAttributes<T>:class org.apache.camel.component.mock.MockEndpoint
      BeanAttributes.getQualifiers()
      ProcessBeanAttributes<?>:interface org.apache.camel.TypeConverter
      ProcessBeanAttributes<?>:CdiEventEndpoint<T extends  class java.lang.Object>
      ProcessBeanAttributes<T>:CdiEventEndpoint<T extends  class java.lang.Object>
      BeanAttributes.getQualifiers()
      ProcessBeanAttributes<?>:interface org.apache.camel.ProducerTemplate
      BeanAttributes.getQualifiers()
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventConsumingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventConsumingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventConsumingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventConsumingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventConsumingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventConsumingRoute
      

      For example, the sequence for the EventProducingRoute bean is:

      ProcessBeanAttributes<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      ProcessInjectionPoint<?>:class org.apache.camel.cdi.se.bean.EventProducingRoute
      

      While from the specification, the ProcessInjectionPoint event must be fired before the ProcessBeanAttributes. Note that this sequence differs from one run to another.

      Attachments

        Activity

          People

            rsandtner Reinhard Sandtner
            antonin.stefanutti Antonin Stefanutti
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: