You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2010/03/25 14:35:38 UTC

svn commit: r927397 - /felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationComponentRegistry.java

Author: fmeschbe
Date: Thu Mar 25 13:35:37 2010
New Revision: 927397

URL: http://svn.apache.org/viewvc?rev=927397&view=rev
Log:
FELIX-2231 Prevent IllegalStateException and potential NullPointerException when handling a configuration event (the bundle owning the component may have been stopped concurrently)

Modified:
    felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationComponentRegistry.java

Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationComponentRegistry.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationComponentRegistry.java?rev=927397&r1=927396&r2=927397&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationComponentRegistry.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/config/ConfigurationComponentRegistry.java Thu Mar 25 13:35:37 2010
@@ -157,26 +157,45 @@ public class ConfigurationComponentRegis
                     break;
 
                 case ConfigurationEvent.CM_UPDATED:
-                    final BundleContext bundleContext = cm.getActivator().getBundleContext();
+                    final BundleComponentActivator activator = cm.getActivator();
+                    if ( activator == null )
+                    {
+                        break;
+                    }
+
+                    final BundleContext bundleContext = activator.getBundleContext();
+                    if ( bundleContext == null )
+                    {
+                        break;
+                    }
+
                     final ServiceReference caRef = bundleContext.getServiceReference( ConfigurationAdmin.class
                         .getName() );
                     if ( caRef != null )
                     {
-                        final ConfigurationAdmin ca = ( ConfigurationAdmin ) bundleContext.getService( caRef );
-                        if ( ca != null )
+                        try
                         {
-                            try
+                            final ConfigurationAdmin ca = ( ConfigurationAdmin ) bundleContext.getService( caRef );
+                            if ( ca != null )
                             {
-                                final Dictionary dict = getConfiguration( ca, pid, bundleContext.getBundle().getLocation() );
-                                if ( dict != null )
+                                try
                                 {
-                                    cm.configurationUpdated( pid, dict );
+                                    final Dictionary dict = getConfiguration( ca, pid, bundleContext.getBundle()
+                                        .getLocation() );
+                                    if ( dict != null )
+                                    {
+                                        cm.configurationUpdated( pid, dict );
+                                    }
+                                }
+                                finally
+                                {
+                                    bundleContext.ungetService( caRef );
                                 }
                             }
-                            finally
-                            {
-                                bundleContext.ungetService( caRef );
-                            }
+                        }
+                        catch ( IllegalStateException ise )
+                        {
+                            // If the bundle has been stopped conurrently
                         }
                     }
                     break;