Uploaded image for project: 'Felix'
  1. Felix
  2. FELIX-5956

NPE when invoking a lifecycle runnable method from init method

    XMLWordPrintableJSON

Details

    Description

      When you use a DM lifecycle controller in order to trigger component activation from the @Init method, a NPE is throw if you invoke the lifecylce runnable from the init method.

      For example, the following code:

      @Component
      public class MyServiceImpl implements MyService {
      
          @LifecycleController
          volatile Runnable _start;
      
          @Init
          void init() {
              _start.run(); // immediately trigger service activation
          }
      }
      

      produces the following NPE:

      Caused by: java.lang.NullPointerException
      	at org.apache.felix.dm.runtime.ToggleServiceDependency.activate(ToggleServiceDependency.java:49)
      	at org.apache.felix.dm.runtime.ServiceLifecycleHandler$ComponentStarter.run(ServiceLifecycleHandler.java:431)
      	at org.apache.felix.dependencymanager.samples.hello.annot.ServiceProviderImpl.init(ServiceProviderImpl.java:47)
      	... 65 more
      

      Attachments

        Activity

          People

            pderop Pierre De Rop
            pderop Pierre De Rop
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: