When grabing bundle locks for a refresh operation, we also need to allow
for bundles to be in the UNINSTALLED state, otherwise we cannot refresh
them. (FELIX-3807)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1441072 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 c3650b9..03a4a52 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -2588,13 +2588,11 @@
                     new TreeMap<Long, BundleImpl>(m_installedBundles[IDENTIFIER_MAP_IDX])
                 };
                 target = (BundleImpl) maps[LOCATION_MAP_IDX].remove(bundle._getLocation());
-                maps[IDENTIFIER_MAP_IDX].remove(new Long(target.getBundleId()));
-                m_installedBundles = maps;
-
-                // Put the uninstalled bundle into the uninstalled
-                // list for subsequent refreshing.
                 if (target != null)
                 {
+                    maps[IDENTIFIER_MAP_IDX].remove(new Long(target.getBundleId()));
+                    m_installedBundles = maps;
+
                     // Set the bundle's persistent state to uninstalled.
                     bundle.setPersistentStateUninstalled();
 
@@ -4708,7 +4706,7 @@
         {
             acquireBundleLock(m_bundle,
                     Bundle.INSTALLED | Bundle.RESOLVED | Bundle.STARTING |
-                    Bundle.ACTIVE | Bundle.STOPPING);
+                    Bundle.ACTIVE | Bundle.STOPPING | Bundle.UNINSTALLED);
             try
             {
                 m_oldState = m_bundle.getState();