Split the Felix.shutdownInternal() method in two to fix some issues Felix
noticed in the new shutdown routine; splitting the method helped us avoid
some asymmetry.


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@543485 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index ce90144..bd1e8d2 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -567,7 +567,7 @@
      * the system bundle, cleaning up any bundle remains and shutting down event
      * dispatching.
      */
-    void shutdownInternal()
+    void shutdownInternalStart()
     {
         synchronized (this)
         {
@@ -665,7 +665,10 @@
                 }
             }
         }
+    }
 
+    void shutdownInternalFinish()
+    {
         // Notify any waiters that the framework is back in its initial state.
         synchronized (this)
         {
diff --git a/framework/src/main/java/org/apache/felix/framework/SystemBundle.java b/framework/src/main/java/org/apache/felix/framework/SystemBundle.java
index eef8cea..f9e05ad 100644
--- a/framework/src/main/java/org/apache/felix/framework/SystemBundle.java
+++ b/framework/src/main/java/org/apache/felix/framework/SystemBundle.java
@@ -356,10 +356,11 @@
 
         public void run()
         {
-            // First, stop all other bundles.
+            // First, start the framework shutdown, which will
+            // stop all bundles.
             try
             {
-                getFelix().shutdownInternal();
+                getFelix().shutdownInternalStart();
             }
             catch (Exception ex)
             {
@@ -397,6 +398,18 @@
                     }
                 }
             }
+
+            // Lastly, complete the shutdown.
+            try
+            {
+                getFelix().shutdownInternalFinish();
+            }
+            catch (Exception ex)
+            {
+                getFelix().getLogger().log(
+                    Logger.LOG_ERROR,
+                    "SystemBundle: Error while shutting down.", ex);
+            }
         }
     }