From f12173bac6175be732dfe42dc8ffb45ccbf68652 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Fri, 17 Apr 2015 15:55:33 -0500 Subject: Bug 464084 - Update the felix resolver implementation to the latest - update to use the term delta --- .../src/org/apache/felix/resolver/Candidates.java | 31 +++++++++++++--------- .../org/apache/felix/resolver/ResolverImpl.java | 7 +++-- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java index e5501d488..8ab895c8d 100644 --- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java +++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/Candidates.java @@ -73,7 +73,7 @@ class Candidates private final Map m_subtitutableMap; - private final OpenHashMapSet m_path; + private final OpenHashMapSet m_delta; /** * Private copy constructor used by the copy() method. @@ -86,7 +86,7 @@ class Candidates boolean fragmentsPresent, Map onDemandResources, Map substitutableMap, - OpenHashMapSet path) + OpenHashMapSet delta) { m_mandatoryResources = mandatoryResources; m_dependentMap = dependentMap; @@ -96,7 +96,7 @@ class Candidates m_fragmentsPresent = fragmentsPresent; m_validOnDemandResources = onDemandResources; m_subtitutableMap = substitutableMap; - m_path = path; + m_delta = delta; } /** @@ -111,11 +111,16 @@ class Candidates m_populateResultCache = new LinkedHashMap(); m_validOnDemandResources = validOnDemandResources; m_subtitutableMap = new LinkedHashMap(); - m_path = new OpenHashMapSet(3); + m_delta = new OpenHashMapSet(3); } - public Object getPath() { - return m_path; + /** + * Returns the delta which is the differences in the candidates from the + * original Candidates permutation. + * @return the delta + */ + public Object getDelta() { + return m_delta; } /** @@ -834,11 +839,11 @@ class Candidates { m_candidateMap.remove(req); } - // Update resolution path - CopyOnWriteSet capPath = m_path.get(req); + // Update the delta with the removed capability + CopyOnWriteSet capPath = m_delta.get(req); if (capPath == null) { capPath = new CopyOnWriteSet(); - m_path.put(req, capPath); + m_delta.put(req, capPath); } capPath.add(cap); } @@ -847,11 +852,11 @@ class Candidates { List l = m_candidateMap.get(req); l.removeAll(caps); - // Update resolution path - CopyOnWriteSet capPath = m_path.get(req); + // Update candidates delta with the removed capabilities. + CopyOnWriteSet capPath = m_delta.get(req); if (capPath == null) { capPath = new CopyOnWriteSet(); - m_path.put(req, capPath); + m_delta.put(req, capPath); } capPath.addAll(caps); return l; @@ -1272,7 +1277,7 @@ class Candidates m_fragmentsPresent, m_validOnDemandResources, m_subtitutableMap, - m_path.deepClone()); + m_delta.deepClone()); } public void dump(ResolveContext rc) diff --git a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java index 381240b94..2264826a8 100644 --- a/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java +++ b/bundles/org.eclipse.osgi/felix/src/org/apache/felix/resolver/ResolverImpl.java @@ -208,7 +208,7 @@ public class ResolverImpl implements Resolver } } - Set donePaths = new HashSet(); + Set processedDeltas = new HashSet(); Map faultyResources = null; do { @@ -221,8 +221,11 @@ public class ResolverImpl implements Resolver { break; } - if (!donePaths.add(allCandidates.getPath())) + // The delta is used to detect that we have already processed this particular permutation + if (!processedDeltas.add(allCandidates.getDelta())) { + // This permutation has already been tried + // Don't try it again continue; } -- cgit v1.2.3