Consistently permutate candidates. (FELIX-2037)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@920439 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
index d15827d..436643d 100644
--- a/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
+++ b/framework/src/main/java/org/apache/felix/framework/resolver/ResolverImpl.java
@@ -1155,36 +1155,9 @@
                     else if ((currentImportedBlame != null)
                         && !isCompatible(currentImportedBlame.m_cap, candSourceBlame.m_cap, modulePkgMap))
                     {
-//System.out.println("+++ CIB " + currentImportedBlame + " SB " + sourceBlame);
-                        // Try to remove the previously selected candidate associated
-                        // with the requirement blamed for adding the constraint. This
-                        // Permutate the candidate map.
-                        if (currentImportedBlame.m_reqs.size() != 0)
-                        {
-                            // Permutate the candidate map.
-                            for (int reqIdx = 0; reqIdx < currentImportedBlame.m_reqs.size(); reqIdx++)
-                            {
-                                Map<Requirement, Set<Capability>> copy = copyCandidateMap(candidateMap);
-                                Set<Capability> candidates =
-                                    copy.get(currentImportedBlame.m_reqs.get(reqIdx));
-                                Iterator it = candidates.iterator();
-                                it.next();
-                                it.remove();
-// TODO: PROTO3 RESOLVER - We could check before doing the candidate map copy.
-                                if (candidates.size() > 0)
-                                {
-                                    m_candidatePermutations.add(copy);
-                                }
-                            }
-                        }
-
-                        throw new ResolveException(
-                            "Constraint violation for package '" + usedPkgName
-                            + "' when resolving module " + current
-                            + " between existing constraint "
-                            + currentImportedBlame
-                            + " and candidate constraint "
-                            + candSourceBlame, null, null);
+                        permutateCandidates(
+                            current, usedPkgName, currentImportedBlame,
+                            candSourceBlame, candidateMap);
                     }
                 }