Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
scr-2.1.28
-
None
Description
The following exception occurs when a component's dynamic injected services of same type are unbound.
The following stacktrace has been generated by SCR-2.1.18 though.
java.lang.NullPointerExceptionjava.lang.NullPointerException at java.util.TreeMap.rotateLeft(TreeMap.java:2224) at java.util.TreeMap.fixAfterDeletion(TreeMap.java:2397) at java.util.TreeMap.deleteEntry(TreeMap.java:2332) at java.util.TreeMap.remove(TreeMap.java:608) at org.apache.felix.scr.impl.inject.field.FieldHandler.updateField(FieldHandler.java:248) at org.apache.felix.scr.impl.inject.field.FieldHandler.access$400(FieldHandler.java:49) at org.apache.felix.scr.impl.inject.field.FieldHandler$Resolved.invoke(FieldHandler.java:422) at org.apache.felix.scr.impl.inject.field.FieldHandler$ReferenceMethodImpl.invoke(FieldHandler.java:492) at org.apache.felix.scr.impl.manager.DependencyManager.invokeUnbindMethod(DependencyManager.java:1927) at org.apache.felix.scr.impl.manager.SingleComponentManager.invokeUnbindMethod(SingleComponentManager.java:458) at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:382) at org.apache.felix.scr.impl.manager.DependencyManager$MultipleDynamicCustomizer.removedService(DependencyManager.java:294) at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1242) at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerRemoved(ServiceTracker.java:1137) at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.untrack(ServiceTracker.java:997) at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1176) at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:125) at org.apache.felix.framework.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:990) at org.apache.felix.framework.EventDispatcher.fireEventImmediately(EventDispatcher.java:838) at org.apache.felix.framework.EventDispatcher.fireServiceEvent(EventDispatcher.java:545) at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:4833) at org.apache.felix.framework.Felix.access$000(Felix.java:112) at org.apache.felix.framework.Felix$1.serviceChanged(Felix.java:434) at org.apache.felix.framework.ServiceRegistry.unregisterService(ServiceRegistry.java:170) at org.apache.felix.framework.ServiceRegistrationImpl.unregister(ServiceRegistrationImpl.java:145) at org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory.unregisterFirmwareUpdateHandler(BaseThingHandlerFactory.java:310) at org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory.unregisterHandler(BaseThingHandlerFactory.java:277) at org.eclipse.smarthome.core.thing.internal.ThingManagerImpl.doUnregisterHandler(ThingManagerImpl.java:845) at org.eclipse.smarthome.core.thing.internal.ThingManagerImpl.unregisterHandler(ThingManagerImpl.java:835) at org.eclipse.smarthome.core.thing.internal.ThingManagerImpl.unregisterAndDisposeHandler(ThingManagerImpl.java:916) at org.eclipse.smarthome.core.thing.internal.ThingManagerImpl.thingRemoved(ThingManagerImpl.java:491) at org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.notifyTrackers(ThingRegistryImpl.java:218) at org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.notifyListenersAboutRemovedElement(ThingRegistryImpl.java:138) at org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.notifyListenersAboutRemovedElement(ThingRegistryImpl.java:54) at org.eclipse.smarthome.core.common.registry.AbstractRegistry.removed(AbstractRegistry.java:243) at org.eclipse.smarthome.core.common.registry.AbstractRegistry.removed(AbstractRegistry.java:55) at org.eclipse.smarthome.core.common.registry.AbstractProvider.notifyListeners(AbstractProvider.java:64) at org.eclipse.smarthome.core.common.registry.AbstractProvider.notifyListeners(AbstractProvider.java:80) at org.eclipse.smarthome.core.common.registry.AbstractProvider.notifyListenersAboutRemovedElement(AbstractProvider.java:88) at org.eclipse.smarthome.core.common.registry.AbstractManagedProvider.remove(AbstractManagedProvider.java:104) at org.eclipse.smarthome.core.common.registry.AbstractRegistry.remove(AbstractRegistry.java:342) at org.eclipse.smarthome.core.thing.internal.ThingRegistryImpl.forceRemove(ThingRegistryImpl.java:105) at org.eclipse.smarthome.core.thing.internal.ThingManagerImpl.lambda$notifyRegistryAboutForceRemove$12(ThingManagerImpl.java:1013) at com.qivicon.runtime.executors.impl.ScheduledExecutorServiceImpl$NamedRunnable.run(ScheduledExecutorServiceImpl.java:80) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)FrameworkEvent error
The problem occurred when multiple injected services tried to be removed from the component's injection. It is highly likely because of the usage of TreeMap in such concurrent environment. Since TreeMap has never been written to be used in a concurrent environment, we should use ConcurrentSkipListMap instead as all the features of TreeMap have been introduced in ConcurrentSkipListMap and it is very much suitable for concurrent environment.
Attachments
Issue Links
- links to