If a bundle is uninstalled more than once, the subsequent calls
should not attempt to cache the bundle headers for the default
locale. (FELIX-2840)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1070949 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
index 8b215c7..7a677ac 100644
--- a/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/BundleImpl.java
@@ -964,14 +964,22 @@
                 AdminPermission.LIFECYCLE));
         }
 
-        // After a bundle is uninstalled, rhe spec says getHeaders() should
+        // After a bundle is uninstalled, the spec says getHeaders() should
         // return the localized headers for the default locale at the time of
-        // of uninstall. So, let's clear the existing header cache and populate
-        // it with the headers for the default locale.
+        // of uninstall. So, let's clear the existing header cache to throw
+        // away any other locales and populate it with the headers for the
+        // default locale. We only do this if there are multiple cached locales
+        // and if the default locale is not cached. If this method is called
+        // more than once, then subsequent calls will do nothing here since
+        // only the default locale will be left in the header cache.
         synchronized (m_cachedHeaders)
         {
-            m_cachedHeaders.clear();
-            Map map = getCurrentLocalizedHeader(Locale.getDefault().toString());
+            if ((m_cachedHeaders.size() > 1)
+                || !m_cachedHeaders.containsKey(Locale.getDefault().toString()))
+            {
+                m_cachedHeaders.clear();
+                Map map = getCurrentLocalizedHeader(Locale.getDefault().toString());
+            }
         }
 
         // Uninstall the bundle.