Bug 559118 - Don't fail with runtime exception when substitutes are not
handled correctly
This doesn't impact the framework, but the resolver is also registered
as a service and used by others. The original fix would cause a runtime
exception if no sources could be found for a blamed used capability.
The previous resolver implementation would silently ignore the source
and it would not impact the used class space. This still produces a
valid class space according to what the resolve context is giving the
resolver to work with.
We will just log an info message if this happens.
Change-Id: I34c61efa33a703c66763197146d09a62f09f9ad8
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 b06d432..6c9b278 100755
--- 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
@@ -807,7 +807,7 @@
return resourcePkgs;
}
- private static void computeUses(
+ private void computeUses(
ResolveSession session,
Map<Resource, List<WireCandidate>> allWireCandidates,
Map<Resource, Packages> resourcePkgMap,
@@ -1016,7 +1016,7 @@
}
}
- private static void mergeUses(
+ private void mergeUses(
ResolveSession session, Resource current, Packages currentPkgs,
Capability mergeCap, List<Requirement> blameReqs, Capability matchingCap,
Map<Resource, Packages> resourcePkgMap,
@@ -1122,7 +1122,7 @@
}
}
- private static Map<Resource, Packages> calculatePackageSpaces(
+ private Map<Resource, Packages> calculatePackageSpaces(
final ResolveSession session,
final Candidates allCandidates,
Collection<Resource> hosts)
@@ -1279,7 +1279,7 @@
return uses;
}
- private static void addUsedBlames(
+ private void addUsedBlames(
ArrayMap<Set<Capability>, UsedBlames> usedBlames, Collection<Blame> blames, Capability matchingCap, Map<Resource, Packages> resourcePkgMap)
{
Set<Capability> usedCaps;
@@ -1295,7 +1295,15 @@
usedCaps.addAll(getPackageSources(blame.m_cap, resourcePkgMap));
}
}
-
+ if (usedCaps.isEmpty())
+ {
+ // This most likely is an issue with the resolve context.
+ // To avoid total failure we do not add blames if there is
+ // no source capabilities
+ m_logger.log(Logger.LOG_INFO,
+ "Package sources are empty for used capability: " + blames);
+ return;
+ }
// Find UsedBlame that uses the same capability as the new blame.
UsedBlames addToBlame = usedBlames.getOrCompute(usedCaps);
// Add the new Blames and record the matching capability cause