felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r927394 - /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
Date Thu, 25 Mar 2010 13:30:26 GMT
Author: fmeschbe
Date: Thu Mar 25 13:30:26 2010
New Revision: 927394

URL: http://svn.apache.org/viewvc?rev=927394&view=rev
Log:
FELIX-2231 Prevent NullPointerException and uncaught IllegalStateException if bundle has been
stopped while the component is being started

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java?rev=927394&r1=927393&r2=927394&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
(original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/manager/DependencyManager.java
Thu Mar 25 13:30:26 2010
@@ -29,6 +29,7 @@ import java.util.Map;
 
 import org.apache.felix.scr.Component;
 import org.apache.felix.scr.Reference;
+import org.apache.felix.scr.impl.BundleComponentActivator;
 import org.apache.felix.scr.impl.helper.BindMethod;
 import org.apache.felix.scr.impl.helper.UnbindMethod;
 import org.apache.felix.scr.impl.helper.UpdatedMethod;
@@ -570,11 +571,29 @@ public class DependencyManager implement
     {
         if ( hasGetPermission() )
         {
+            // component activator may be null if disposed concurrently
+            BundleComponentActivator bca = m_componentManager.getActivator();
+            if ( bca == null )
+            {
+                return null;
+            }
+
+            // get bundle context, may be null if component deactivated since getting bca
+            BundleContext bc = bca.getBundleContext();
+            if ( bc == null )
+            {
+                return null;
+            }
+
             try
             {
-                return m_componentManager.getActivator().getBundleContext().getServiceReferences(
+                return bc.getServiceReferences(
                     m_dependencyMetadata.getInterface(), targetFilter );
             }
+            catch ( IllegalStateException ise )
+            {
+                // bundle context is not valid any longer, cannot log
+            }
             catch ( InvalidSyntaxException ise )
             {
                 m_componentManager.log( LogService.LOG_ERROR, "Unexpected problem with filter
''{0}''", new Object[]



Mime
View raw message