felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r1544179 - /felix/trunk/utils/src/main/java/org/apache/felix/utils/extender/AbstractExtender.java
Date Thu, 21 Nov 2013 13:52:28 GMT
Author: gnodet
Date: Thu Nov 21 13:52:27 2013
New Revision: 1544179

URL: http://svn.apache.org/r1544179
Log:
[FELIX-4326] Possible Invalid BundleContext exception when shutting down the extender

Modified:
    felix/trunk/utils/src/main/java/org/apache/felix/utils/extender/AbstractExtender.java

Modified: felix/trunk/utils/src/main/java/org/apache/felix/utils/extender/AbstractExtender.java
URL: http://svn.apache.org/viewvc/felix/trunk/utils/src/main/java/org/apache/felix/utils/extender/AbstractExtender.java?rev=1544179&r1=1544178&r2=1544179&view=diff
==============================================================================
--- felix/trunk/utils/src/main/java/org/apache/felix/utils/extender/AbstractExtender.java
(original)
+++ felix/trunk/utils/src/main/java/org/apache/felix/utils/extender/AbstractExtender.java
Thu Nov 21 13:52:27 2013
@@ -52,6 +52,7 @@ public abstract class AbstractExtender i
     private final ConcurrentMap<Bundle, Extension> extensions = new ConcurrentHashMap<Bundle,
Extension>();
     private final ConcurrentMap<Bundle, FutureTask> destroying = new ConcurrentHashMap<Bundle,
FutureTask>();
     private volatile boolean stopping;
+    private volatile boolean stopped;
 
     private boolean synchronous;
     private boolean preemptiveShutdown;
@@ -115,6 +116,7 @@ public abstract class AbstractExtender i
 
     public void stop(BundleContext context) throws Exception {
         stopping = true;
+        this.context.removeBundleListener(this);
         while (!extensions.isEmpty()) {
             Collection<Bundle> toDestroy = chooseBundlesToDestroy(extensions.keySet());
             if (toDestroy == null || toDestroy.isEmpty()) {
@@ -134,6 +136,7 @@ public abstract class AbstractExtender i
             }
             executors = null;
         }
+        stopped = true;
     }
 
     protected void doStart() throws Exception {
@@ -172,6 +175,9 @@ public abstract class AbstractExtender i
 
 
     public void bundleChanged(BundleEvent event) {
+        if (stopped) {
+            return;
+        }
         Bundle bundle = event.getBundle();
         if (bundle.getState() != Bundle.ACTIVE && bundle.getState() != Bundle.STARTING)
{
             // The bundle is not in STARTING or ACTIVE state anymore



Mime
View raw message