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

SCR activates a service component while the containing bundle is stopping.

    XMLWordPrintableJSON

Details

    Description

      I've got the following setup:

      Bundle 1: Implements a pattern similar to the extender pattern. A bundle tracker monitors bundles containing a certain configuration entry. Each time a bundle with the coniguration entry enters or leaves the ACTIVE state, a service of the interface "com.example.bundle1.Bundle1Service" is unregistered and a new service with the same interface is re-registered.

      Bundle 2: Has an immediate service component with the following configuration:

      <component name="Bundle2Component" immediate="true" xmlns="http://www.osgi.org/xmlns/scr/v1.1.0">

      <implementation class="com.example.bundle2.TestComponent" />

      <service>
      <provide interface="java.lang.Object" />
      </service>

      <reference
      name="bundle1service"
      interface="com.example.bundle1.Bundle1Service"
      cardinality="1..1"
      policy="static"
      bind="setBundle1Service" />

      </component>

      Situation: Both bundles have been started. The service component from bundle 2 is active and the reference is bound to the current Bundle1Service exported from bundle 1.

      Now, when i stop bundle 2 the following occur:

      1. The state of bundle 2 is changed to STOPPING
      2. The state change is discovered by the service tracker in bundle 1 which causes it to unregister the Bundle1Service and then register a a new Bundle1Service.
      3. The SCR discovers that the bundle1service reference of the component has become unsatisfied and deactivates the component.
      4. The SCR discovers that the bundle1service reference of the component has become satisfied (with a new service) and activates the component.
      5. The SCR tries to export the newly activated component as a service, but fails since the bundle is stopping.

      The problem seems to be that SCR has not discovered that the bundle is STOPPING and disabled the component. A simple fix might be to check whether to disable the component based on bundle status before activating a new instance of the component.

      Attachments

        Activity

          People

            fmeschbe Felix Meschberger
            sorenp Soren Petersen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: