Details

      Description

      We've been encountering several exceptions thrown intermittently from DS. They generally look like ungetting service on a disposed-of SCR BundleComponentActivator, ComponentManager, or DependencyManager. There may be two threads trying to shut down the same bundles at the same time. I'm not sure how to investigate the root cause or if this kind of behavior is expected. The SCR code generally doesn't look very thread safe. It's easy to "fix" the specific problems we see by adding more checks to the SCR code so the NPEs are avoided, or attempted use of closed bundle contexts are caught and ignored. I'd be happy to keep looking into this but could use some hints about what should be happening. Unless someone can come up with a better explanation and fix it would be great meanwhile to patch the code to avoid throwing the exceptions.

      Here are some of the typical stack traces we see:

      Stack Dump = org.osgi.framework.ServiceException: Exception in org.apache.felix.scr.impl.manager.DelayedComponentManager.ungetService()
      at org.eclipse.osgi.internal.serviceregistry.ServiceUse.releaseService(ServiceUse.java:287)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.releaseService(ServiceRegistrationImpl.java:562)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.releaseServicesInUse(ServiceRegistry.java:665)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.close(BundleContextImpl.java:91)
      at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:514)
      at org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:565)
      at org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1161)
      at org.eclipse.osgi.framework.internal.core.StartLevelManager.decFWSL(StartLevelManager.java:595)
      at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:257)
      at org.eclipse.osgi.framework.internal.core.StartLevelManager.shutdown(StartLevelManager.java:215)
      at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.suspend(InternalSystemBundle.java:284)
      at org.eclipse.osgi.framework.internal.core.Framework.shutdown(Framework.java:691)
      at org.eclipse.osgi.framework.internal.core.Framework.close(Framework.java:598)
      at org.eclipse.osgi.framework.internal.core.InternalSystemBundle$1.run(InternalSystemBundle.java:261)
      at java.lang.Thread.run(Thread.java:680)
      Caused by: java.lang.NullPointerException
      at org.apache.felix.scr.impl.BundleComponentActivator.log(BundleComponentActivator.java:614)
      at org.apache.felix.scr.impl.BundleComponentActivator.log(BundleComponentActivator.java:589)
      at org.apache.felix.scr.impl.manager.AbstractComponentManager.log(AbstractComponentManager.java:633)
      at org.apache.felix.scr.impl.manager.AbstractComponentManager$State.log(AbstractComponentManager.java:1000)
      at org.apache.felix.scr.impl.manager.AbstractComponentManager$State.ungetService(AbstractComponentManager.java:964)
      at org.apache.felix.scr.impl.manager.DelayedComponentManager.ungetService(DelayedComponentManager.java:114)
      at org.eclipse.osgi.internal.serviceregistry.ServiceUse$3.run(ServiceUse.java:277)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.eclipse.osgi.internal.serviceregistry.ServiceUse.releaseService(ServiceUse.java:275)
      ... 14 more

      Stack Dump = org.osgi.framework.ServiceException: Exception in org.apache.felix.scr.impl.manager.DelayedComponentManager.ungetService()
      at org.eclipse.osgi.internal.serviceregistry.ServiceUse.releaseService(ServiceUse.java:287)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.releaseService(ServiceRegistrationImpl.java:562)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:245)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.unregisterServices(ServiceRegistry.java:635)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.close(BundleContextImpl.java:88)
      at org.eclipse.osgi.framework.internal.core.BundleHost.stopWorker(BundleHost.java:514)
      at org.eclipse.osgi.framework.internal.core.AbstractBundle.suspend(AbstractBundle.java:565)
      at org.eclipse.osgi.framework.internal.core.Framework.suspendBundle(Framework.java:1161)
      at org.eclipse.osgi.framework.internal.core.StartLevelManager.decFWSL(StartLevelManager.java:595)
      at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:257)
      at org.eclipse.osgi.framework.internal.core.StartLevelManager.shutdown(StartLevelManager.java:215)
      at org.eclipse.osgi.framework.internal.core.InternalSystemBundle.suspend(InternalSystemBundle.java:284)
      at org.eclipse.osgi.framework.internal.core.Framework.shutdown(Framework.java:691)
      at org.eclipse.osgi.framework.internal.core.Framework.close(Framework.java:598)
      at org.eclipse.osgi.framework.internal.core.InternalSystemBundle$1.run(InternalSystemBundle.java:261)
      at java.lang.Thread.run(Thread.java:680)
      Caused by: java.lang.IllegalStateException: BundleContext is no longer valid
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.checkValid(BundleContextImpl.java:931)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.ungetService(BundleContextImpl.java:634)
      at org.apache.felix.scr.impl.manager.DependencyManager.ungetService(DependencyManager.java:819)
      at org.apache.felix.scr.impl.manager.DependencyManager.unbind(DependencyManager.java:1000)
      at org.apache.felix.scr.impl.manager.DependencyManager.close(DependencyManager.java:880)
      at org.apache.felix.scr.impl.manager.ImmediateComponentManager.disposeImplementationObject(ImmediateComponentManager.java:268)
      at org.apache.felix.scr.impl.manager.ImmediateComponentManager.deleteComponent(ImmediateComponentManager.java:135)
      at org.apache.felix.scr.impl.manager.DelayedComponentManager.deleteComponent(DelayedComponentManager.java:67)
      at org.apache.felix.scr.impl.manager.AbstractComponentManager$Active.ungetService(AbstractComponentManager.java:1266)
      at org.apache.felix.scr.impl.manager.DelayedComponentManager.ungetService(DelayedComponentManager.java:114)
      at org.eclipse.osgi.internal.serviceregistry.ServiceUse$3.run(ServiceUse.java:277)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.eclipse.osgi.internal.serviceregistry.ServiceUse.releaseService(ServiceUse.java:275)
      ... 15 more

      -------
      This one is from FELIX-3307:

      java.lang.NullPointerException
      at org.apache.felix.scr.impl.manager.DependencyManager.invokeBindMethod(DependencyManager.java:1028)
      at org.apache.felix.scr.impl.manager.DependencyManager.serviceAdded(DependencyManager.java:308)
      at org.apache.felix.scr.impl.manager.DependencyManager.serviceChanged(DependencyManager.java:170)
      at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:104)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:861)
      at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
      at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:819)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:771)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:130)
      at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:214)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:433)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:451)
      at org.eclipse.osgi.framework.internal.core.BundleContextImpl.registerService(BundleContextImpl.java:950)

      1. FELIX-3345-5.diff
        2 kB
        David Jencks
      2. FELIX-3345-4.diff
        85 kB
        David Jencks
      3. FELIX-3345-3.diff
        88 kB
        David Jencks
      4. FELIX-3345-2.diff
        8 kB
        David Jencks
      5. FELIX-3345.diff
        5 kB
        David Jencks

        Issue Links

          Activity

          David Jencks made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s scr-1.6.2 [ 12315248 ]
          Resolution Fixed [ 1 ]
          Felix Meschberger made changes -
          Assignee Felix Meschberger [ fmeschbe ]
          David Jencks made changes -
          Attachment FELIX-3345-5.diff [ 12516753 ]
          David Jencks made changes -
          Attachment FELIX-3345-4.diff [ 12515670 ]
          David Jencks made changes -
          Attachment FELIX-3345-3.diff [ 12515547 ]
          David Jencks made changes -
          Attachment FELIX-3345-2.diff [ 12514042 ]
          David Jencks made changes -
          Link This issue incorporates FELIX-3307 [ FELIX-3307 ]
          David Jencks made changes -
          Field Original Value New Value
          Attachment FELIX-3345.diff [ 12514032 ]
          David Jencks created issue -

            People

            • Assignee:
              Felix Meschberger
              Reporter:
              David Jencks
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development