Thomas Watson created FELIX-6055: ------------------------------------ Summary: NullPointerException possible because ServiceReference.getBundle() can return null Key: FELIX-6055 URL: https://issues.apache.org/jira/browse/FELIX-6055 Project: Felix Issue Type: Bug Components: Declarative Services (SCR) Affects Versions: scr-2.1.14 Reporter: Thomas Watson
There are a couple of places in the SCR code where it gets the bundle object from ServiceReference.getBundle(). Unfortunately this method can return null when a service becomes unregistered. This can lead to FrameworkEvent errors with NPEs that look like the following: {code} FrameworkEvent ERROR java.lang.NullPointerException at org.apache.felix.scr.impl.runtime.ServiceComponentRuntimeImpl.serviceChanged(ServiceComponentRuntimeImpl.java:491) at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:112) at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:923) at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:233) at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:865) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:804) at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.setProperties(ServiceRegistrationImpl.java:171) {code} We should protect against such cases. -- This message was sent by Atlassian JIRA (v7.6.3#76005)