diff options
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/Candidates.java | 5 | ||||
-rw-r--r-- | bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/ResolverImpl.java | 18 |
2 files changed, 20 insertions, 3 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/Candidates.java b/bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/Candidates.java index 366605b8d..b5429eb3a 100644 --- a/bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/Candidates.java +++ b/bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/Candidates.java @@ -746,6 +746,11 @@ class Candidates return m_candidateMap.get(req); } + public void clearCandidates(Requirement req) + { + m_candidateMap.remove(req); + } + /** * Merges fragments into their hosts. It does this by wrapping all host * modules and attaching their selected fragments, removing all unselected diff --git a/bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/ResolverImpl.java b/bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/ResolverImpl.java index d0e396751..d6d3910fe 100644 --- a/bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/ResolverImpl.java +++ b/bundles/org.eclipse.osgi/container/src/org/apache/felix/resolver/ResolverImpl.java @@ -1237,11 +1237,15 @@ public class ResolverImpl implements Resolver // requirement; there may be no candidates if the resource // associated with the requirement is already resolved. List<Capability> candidates = permutation.getCandidates(req); - if ((candidates != null) && (candidates.size() > 1)) + if ((candidates != null) && (candidates.size() > 1 || Util.isOptional(req))) { mutated.add(req); // Remove the conflicting candidate. candidates.remove(0); + if (candidates.isEmpty()) + { + permutation.clearCandidates(req); + } // Continue with the next uses constraint. break; } @@ -1346,11 +1350,15 @@ public class ResolverImpl implements Resolver // requirement; there may be no candidates if the resource // associated with the requirement is already resolved. List<Capability> candidates = permutation.getCandidates(req); - if ((candidates != null) && (candidates.size() > 1)) + if ((candidates != null) && (candidates.size() > 1 || Util.isOptional(req))) { mutated.add(req); // Remove the conflicting candidate. candidates.remove(0); + if (candidates.isEmpty()) + { + permutation.clearCandidates(req); + } // Continue with the next uses constraint. break; } @@ -1470,11 +1478,15 @@ public class ResolverImpl implements Resolver if (!Util.isMultiple(req)) { List<Capability> candidates = allCandidates.getCandidates(req); - if ((candidates != null) && (candidates.size() > 1)) + if ((candidates != null) && (candidates.size() > 1 || Util.isOptional(req))) { Candidates perm = allCandidates.copy(); candidates = perm.getCandidates(req); candidates.remove(0); + if (candidates.isEmpty()) + { + perm.clearCandidates(req); + } permutations.add(perm); } } |