Fragments may get re-resolved, so we have to special case this situation
to create a union of its host wires. (FELIX-2950)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1149694 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
index d03148f..a398d9e 100644
--- a/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
+++ b/framework/src/main/java/org/apache/felix/framework/StatefulResolver.java
@@ -747,6 +747,16 @@
                 List<BundleWire> bundleWires =
                     new ArrayList<BundleWire>(resolverWires.size());
 
+                // Need to special case fragments since they may already have
+                // wires if they are already attached to another host; if that
+                // is the case, then we want to merge the old host wires with
+                // the new ones.
+                if ((revision.getWiring() != null) && Util.isFragment(revision))
+                {
+                    // Fragments only have host wires, so just add them all.
+                    bundleWires.addAll(revision.getWiring().getRequiredWires(null));
+                }
+
                 // Loop through resolver wires to calculate the package
                 // space implied by the wires as well as to record the
                 // dependencies.