Felix
  1. Felix
  2. FELIX-3126

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

    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.

        Activity

        Soren Petersen created issue -
        Felix Meschberger made changes -
        Field Original Value New Value
        Assignee Felix Meschberger [ fmeschbe ]
        Felix Meschberger committed 1181999 (2 files)
        Hide
        Felix Meschberger added a comment -

        Committed a fix in Rev. 1181999 which prevents the component from being enabled or activated while the bundle is being stopped.

        Can you please check, whether this helps you use case ? Thanks.

        Show
        Felix Meschberger added a comment - Committed a fix in Rev. 1181999 which prevents the component from being enabled or activated while the bundle is being stopped. Can you please check, whether this helps you use case ? Thanks.
        Hide
        Felix Meschberger added a comment -

        Considering this issue fixed. If it ain't so, we can still reopen.

        Show
        Felix Meschberger added a comment - Considering this issue fixed. If it ain't so, we can still reopen.
        Felix Meschberger made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s scr-1.6.2 [ 12315248 ]
        Resolution Fixed [ 1 ]
        Hide
        Felix Meschberger added a comment -

        Close after release

        Show
        Felix Meschberger added a comment - Close after release
        Felix Meschberger made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Felix Meschberger
            Reporter:
            Soren Petersen
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development