FELIX-2382: do not refresh host bundles that have just been installed

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@953589 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
index c8815df..16e2a5e 100644
--- a/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
+++ b/karaf/features/core/src/main/java/org/apache/felix/karaf/features/internal/FeaturesServiceImpl.java
@@ -393,22 +393,26 @@
 
     protected Set<Bundle> findBundlesWithFramentsToRefresh(InstallationState state) {
         Set<Bundle> bundles = new HashSet<Bundle>();
-        for (Bundle b : state.installed) {
-            String hostHeader = (String) b.getHeaders().get(Constants.FRAGMENT_HOST);
-            if (hostHeader != null) {
-                Clause[] clauses = Parser.parseHeader(hostHeader);
-                if (clauses != null && clauses.length > 0) {
-                    Clause path = clauses[0];
-                    for (Bundle hostBundle : state.bundles) {
-                        if (hostBundle.getSymbolicName().equals(path.getName())) {
-                            String ver = path.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
-                            if (ver != null) {
-                                VersionRange v = VersionRange.parseVersionRange(ver);
-                                if (v.contains(hostBundle.getVersion())) {
+        Set<Bundle> oldBundles = new HashSet<Bundle>(state.bundles);
+        oldBundles.removeAll(state.installed);
+        if (!oldBundles.isEmpty()) {
+            for (Bundle b : state.installed) {
+                String hostHeader = (String) b.getHeaders().get(Constants.FRAGMENT_HOST);
+                if (hostHeader != null) {
+                    Clause[] clauses = Parser.parseHeader(hostHeader);
+                    if (clauses != null && clauses.length > 0) {
+                        Clause path = clauses[0];
+                        for (Bundle hostBundle : oldBundles) {
+                            if (hostBundle.getSymbolicName().equals(path.getName())) {
+                                String ver = path.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
+                                if (ver != null) {
+                                    VersionRange v = VersionRange.parseVersionRange(ver);
+                                    if (v.contains(hostBundle.getVersion())) {
+                                        bundles.add(hostBundle);
+                                    }
+                                } else {
                                     bundles.add(hostBundle);
                                 }
-                            } else {
-                                bundles.add(hostBundle);
                             }
                         }
                     }