You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2011/08/26 19:21:05 UTC

svn commit: r1162178 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java

Author: rickhall
Date: Fri Aug 26 17:21:05 2011
New Revision: 1162178

URL: http://svn.apache.org/viewvc?rev=1162178&view=rev
Log:
Need to invalidate bundle context earlier too if there is an activation
failure to avoid race conditions on runaway threads adding listeners or
services. (FELIX-3082)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=1162178&r1=1162177&r2=1162178&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java Fri Aug 26 17:21:05 2011
@@ -2017,6 +2017,13 @@ public class Felix extends BundleImpl im
                 // Clean up the bundle activator
                 bundle.setActivator(null);
 
+                // Clean up the bundle context.
+                // We invalidate this first to make sure it cannot be used
+                // after stopping the activator.
+                BundleContextImpl bci = (BundleContextImpl) bundle._getBundleContext();
+                bci.invalidate();
+                bundle.setBundleContext(null);
+
                 // Unregister any services offered by this bundle.
                 m_registry.unregisterServices(bundle);
 
@@ -2024,11 +2031,7 @@ public class Felix extends BundleImpl im
                 m_registry.ungetServices(bundle);
 
                 // Remove any listeners registered by this bundle.
-                m_dispatcher.removeListeners(bundle._getBundleContext());
-
-                // Clean up the bundle context.
-                ((BundleContextImpl) bundle._getBundleContext()).invalidate();
-                bundle.setBundleContext(null);
+                m_dispatcher.removeListeners(bci);
 
                 // The spec says to expect BundleException or
                 // SecurityException, so rethrow these exceptions.