[FELIX-4942] Do not store permutations on the session
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1690732 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java b/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
index b73ca51..7c3a696 100644
--- a/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
+++ b/resolver/src/main/java/org/apache/felix/resolver/ResolverImpl.java
@@ -85,16 +85,6 @@
m_resolveContext = resolveContext;
}
- List<Candidates> getUsesPermutations()
- {
- return m_usesPermutations;
- }
-
- List<Candidates> getImportPermutations()
- {
- return m_importPermutations;
- }
-
Candidates getMultipleCardCandidates()
{
return m_multipleCardCandidates;
@@ -215,9 +205,12 @@
}
}
- List<Candidates> usesPermutations = session.getUsesPermutations();
- List<Candidates> importPermutations = session.getImportPermutations();
- List<Candidates> substPermutations = new ArrayList<Candidates>();
+ // Holds candidate permutations based on permutating "uses" chains.
+ // These permutations are given higher priority.
+ List<Candidates> usesPermutations = new ArrayList<Candidates>();
+ // Holds candidate permutations based on permutating requirement candidates.
+ // These permutations represent backtracking on previous decisions.
+ List<Candidates> importPermutations = new ArrayList<Candidates>();
// Record the initial candidate permutation.
usesPermutations.add(allCandidates);
@@ -248,10 +241,6 @@
{
allCandidates = importPermutations.remove(0);
}
- else if (!substPermutations.isEmpty())
- {
- allCandidates = substPermutations.remove(0);
- }
else
{
break;
@@ -272,7 +261,7 @@
//allCandidates.dump();
- rethrow = allCandidates.checkSubstitutes( /*substPermutations*/ importPermutations);
+ rethrow = allCandidates.checkSubstitutes(importPermutations);
if (rethrow != null)
{
continue;
@@ -301,7 +290,15 @@
}
Map<Resource, ResolutionError> currentFaultyResources = new HashMap<Resource, ResolutionError>();
- rethrow = checkConsistency(executor, session, allCandidates, currentFaultyResources, hosts, false);
+ rethrow = checkConsistency(
+ executor,
+ session,
+ usesPermutations,
+ importPermutations,
+ allCandidates,
+ currentFaultyResources,
+ hosts,
+ false);
if (!currentFaultyResources.isEmpty())
{
@@ -394,8 +391,6 @@
finally
{
// Always clear the state.
- session.getUsesPermutations().clear();
- session.getImportPermutations().clear();
session.setMultipleCardCandidates(null);
}
}
@@ -407,6 +402,8 @@
private ResolutionError checkConsistency(
Executor executor,
ResolveSession session,
+ List<Candidates> usesPermutations,
+ List<Candidates> importPermutations,
Candidates allCandidates,
Map<Resource, ResolutionError> currentFaultyResources,
Map<Resource, Resource> hosts,
@@ -422,7 +419,7 @@
for (Entry<Resource, Resource> entry : hosts.entrySet())
{
ResolutionError rethrow = checkPackageSpaceConsistency(
- session, entry.getValue(),
+ session, usesPermutations, importPermutations, entry.getValue(),
allCandidates, dynamic, resourcePkgMap, resultCache);
if (rethrow != null)
{
@@ -520,8 +517,8 @@
throw rethrow.toException();
}
- List<Candidates> usesPermutations = session.getUsesPermutations();
- List<Candidates> importPermutations = session.getImportPermutations();
+ List<Candidates> usesPermutations = new ArrayList<Candidates>();
+ List<Candidates> importPermutations = new ArrayList<Candidates>();
// Record the initial candidate permutation.
usesPermutations.add(allCandidates);
@@ -546,7 +543,7 @@
// this case like we do for a normal resolve.
rethrow = checkConsistency(
new DumbExecutor(),
- session, allCandidates,
+ session, usesPermutations, importPermutations, allCandidates,
new OpenHashMap<Resource, ResolutionError>(resourcePkgMap.size()),
Collections.singletonMap(host, allCandidates.getWrappedHost(host)),
true);
@@ -604,8 +601,6 @@
finally
{
// Always clear the state.
- session.getUsesPermutations().clear();
- session.getImportPermutations().clear();
session.setMultipleCardCandidates(null);
}
}
@@ -1237,6 +1232,8 @@
private ResolutionError checkPackageSpaceConsistency(
ResolveSession session,
+ List<Candidates> usesPermutations,
+ List<Candidates> importPermutations,
Resource resource,
Candidates allCandidates,
boolean dynamic,
@@ -1259,9 +1256,6 @@
Candidates permutation = null;
Set<Requirement> mutated = null;
- List<Candidates> importPermutations = session.getImportPermutations();
- List<Candidates> usesPermutations = session.getUsesPermutations();
-
// Check for conflicting imports from fragments.
// TODO: Is this only needed for imports or are generic and bundle requirements also needed?
// I think this is only a special case for fragment imports because they can overlap
@@ -1527,7 +1521,7 @@
if (!resource.equals(cap.getResource()))
{
rethrow = checkPackageSpaceConsistency(
- session, cap.getResource(),
+ session, usesPermutations, importPermutations, cap.getResource(),
allCandidates, false, resourcePkgMap, resultCache);
if (rethrow != null)
{