Skip to content

Commit

Permalink
Fix for TCK test ResolverHookTests.testBeginTriggers
Browse files Browse the repository at this point in the history
The PR #95 changed some of the logic with the triggers
that get passed to resolver hooks.  When doing a refresh
the triggers got replaced with all unresolved revisions
when the triggers were not mandatory.  That is the case
when doing a refreshBundles call. That changed what the
framework passed to resolver hooks for triggers.

This fix saves the original triggers list so that calls
to the resolver hooks use the correct list of revisioins
for the triggers.
  • Loading branch information
tjwatson committed Dec 19, 2023
1 parent fd4fe31 commit 5a71dce
Showing 1 changed file with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ private static int parseInteger(String sInteger, int defaultValue, int minValue)
* merged into the moduleDatabase
*/
ModuleResolutionReport resolveDelta(Collection<ModuleRevision> triggers, boolean triggersMandatory, Collection<ModuleRevision> unresolved, Map<ModuleRevision, ModuleWiring> wiringCopy, ModuleDatabase moduleDatabase) {
if (!triggersMandatory) {
// we are just resolving all bundles optionally
triggers = unresolved;
}
ResolveProcess resolveProcess = new ResolveProcess(unresolved, triggers, triggersMandatory, wiringCopy, moduleDatabase);
return resolveProcess.resolve();
}
Expand Down Expand Up @@ -500,8 +496,9 @@ protected void doLog(int level, String msg, Throwable throwable) {
* back later for other reasons.
*/
private final Collection<ModuleRevision> disabled;
private final Collection<ModuleRevision> triggers;
private final boolean triggersMandatory;
private final Collection<ModuleRevision> toResolve;
private final boolean toResolveMandatory;
private final Collection<ModuleRevision> triggersForHook;
final ModuleDatabase moduleDatabase;
final Map<ModuleRevision, ModuleWiring> wirings;
private final Set<ModuleRevision> previouslyResolved;
Expand All @@ -528,8 +525,14 @@ protected void doLog(int level, String msg, Throwable throwable) {
ResolveProcess(Collection<ModuleRevision> unresolved, Collection<ModuleRevision> triggers, boolean triggersMandatory, Map<ModuleRevision, ModuleWiring> wirings, ModuleDatabase moduleDatabase) {
this.unresolved = unresolved;
this.disabled = new HashSet<>(unresolved);
this.triggers = new ArrayList<>(triggers);
this.triggersMandatory = triggersMandatory;
if (!triggersMandatory) {
// we are just resolving all bundles optionally
this.toResolve = new ArrayList<>(unresolved);
} else {
this.toResolve = new ArrayList<>(triggers);
}
this.triggersForHook = Collections.unmodifiableList(new ArrayList<>(triggers));
this.toResolveMandatory = triggersMandatory;
this.wirings = new HashMap<>(wirings);
this.previouslyResolved = new HashSet<>(wirings.keySet());
this.moduleDatabase = moduleDatabase;
Expand All @@ -540,9 +543,10 @@ protected void doLog(int level, String msg, Throwable throwable) {
this.unresolved = unresolved;
this.disabled = new HashSet<>(unresolved);
ModuleRevision revision = dynamicReq.getRevision();
this.triggers = new ArrayList<>(1);
this.triggers.add(revision);
this.triggersMandatory = false;
this.toResolve = new ArrayList<>(1);
this.toResolve.add(revision);
this.toResolveMandatory = false;
this.triggersForHook = Collections.singletonList(revision);
this.wirings = wirings;
this.previouslyResolved = new HashSet<>(wirings.keySet());
this.moduleDatabase = moduleDatabase;
Expand Down Expand Up @@ -859,7 +863,8 @@ ModuleResolutionReport resolve() {
threadResolving.set(Boolean.TRUE);
try {
try {
hook = adaptor.getResolverHookFactory().begin(InternalUtils.asList((List<? extends BundleRevision>) triggers));
hook = adaptor.getResolverHookFactory()
.begin(InternalUtils.asList((List<? extends BundleRevision>) triggersForHook));
} catch (RuntimeException e) {
if (e.getCause() instanceof BundleException) {
BundleException be = (BundleException) e.getCause();
Expand All @@ -877,7 +882,7 @@ ModuleResolutionReport resolve() {
filterResolvable();
selectSingletons();
// remove disabled from triggers to prevent the resolver from resolving them
if (triggers.removeAll(disabled) && triggersMandatory) {
if (toResolve.removeAll(disabled) && toResolveMandatory) {
throw new ResolutionException(Msg.ModuleResolver_SingletonDisabledError + disabled);
}
if (dynamicReq != null) {
Expand All @@ -890,11 +895,11 @@ ModuleResolutionReport resolve() {
// be sure to remove the revisions from the optional and triggers
// so they no longer attempt to be resolved
Set<Resource> fragmentResources = dynamicAttachWirings.keySet();
triggers.removeAll(fragmentResources);
toResolve.removeAll(fragmentResources);

result.putAll(dynamicAttachWirings);
}
resolveRevisionsInBatch(triggers, triggersMandatory, logger, result);
resolveRevisionsInBatch(toResolve, toResolveMandatory, logger, result);
}
} catch (ResolutionException e) {
re = e;
Expand Down

0 comments on commit 5a71dce

Please sign in to comment.