FELIX-3345 Apply patch FELIX-3345-5.diff by David Jencks (thanks alot)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1298267 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
index 3068384..f89c2fb 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
@@ -816,17 +816,25 @@
Object service = m_bound.remove( serviceReference );
if ( service != null && service != BOUND_SERVICE_SENTINEL )
{
- try
+ BundleComponentActivator activator = m_componentManager.getActivator();
+ if ( activator != null )
{
- m_componentManager.getActivator().getBundleContext().ungetService( serviceReference );
- }
- catch ( IllegalStateException e )
- {
- m_componentManager.log( LogService.LOG_INFO,
- "For dependency {0}, trying to unget ServiceReference {1} on invalid bundle context {2}",
- new Object[]
- { m_dependencyMetadata.getName(), serviceReference.getProperty( Constants.SERVICE_ID ),
- serviceReference }, null );
+ BundleContext bundleContext = activator.getBundleContext();
+ if ( bundleContext != null )
+ {
+ try
+ {
+ bundleContext.ungetService( serviceReference );
+ }
+ catch ( IllegalStateException e )
+ {
+ m_componentManager.log( LogService.LOG_INFO,
+ "For dependency {0}, trying to unget ServiceReference {1} on invalid bundle context {2}",
+ new Object[]
+ { m_dependencyMetadata.getName(), serviceReference.getProperty( Constants.SERVICE_ID ),
+ serviceReference }, null );
+ }
+ }
}
}
}