FELIX-1929 - getStartLevel() always reports requested start level, not active start level


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@888883 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 4c6283a..38a6886 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -960,9 +960,8 @@
             // with each other.
 
             // Determine if we are lowering or raising the
-            // active start level, then udpate active start level.
+            // active start level.
             boolean lowering = (requestedLevel < getActiveStartLevel());
-            m_activeStartLevel = requestedLevel;
 
             synchronized (m_installedBundleLock_Priority2)
             {
@@ -1065,8 +1064,14 @@
                     if (((impl.getPersistentState() == Bundle.ACTIVE)
                         || (impl.getPersistentState() == Bundle.STARTING))
                         && (impl.getStartLevel(getInitialBundleStartLevel())
-                            <= getActiveStartLevel()))
+                            <= requestedLevel))
                     {
+
+                        if (m_activeStartLevel != impl.getStartLevel(getInitialBundleStartLevel()))
+                        {
+                            m_activeStartLevel = impl.getStartLevel(getInitialBundleStartLevel());
+                        }
+                        
                         try
                         {
 // TODO: LAZY - Not sure if this is the best way...
@@ -1088,8 +1093,14 @@
                     else if (((impl.getState() == Bundle.ACTIVE)
                         || (impl.getState() == Bundle.STARTING))
                         && (impl.getStartLevel(getInitialBundleStartLevel())
-                            > getActiveStartLevel()))
+                            > requestedLevel))
                     {
+
+                        if (m_activeStartLevel != impl.getStartLevel(getInitialBundleStartLevel()))
+                        {
+                            m_activeStartLevel = impl.getStartLevel(getInitialBundleStartLevel());
+                        }
+
                         try
                         {
                             stopBundle(impl, false);
@@ -1112,6 +1123,9 @@
                 // is necessary, but it appears to help.
                 bundles[i] = null;
             }
+
+            m_activeStartLevel = requestedLevel;
+
         }
 
         if (getState() == Bundle.ACTIVE)