Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2017-12-12 14:13:32 -0500
committerThomas Watson2017-12-13 10:07:14 -0500
commit6f2b763dc9c65ad86450ee6aec82da56d6c95617 (patch)
tree88a13a001058177e461022ee8d7aea58b41b29a0
parent774ec10b9a292710170dbbc4196d21f6a44c22b5 (diff)
downloadrt.equinox.framework-6f2b763dc9c65ad86450ee6aec82da56d6c95617.tar.gz
rt.equinox.framework-6f2b763dc9c65ad86450ee6aec82da56d6c95617.tar.xz
rt.equinox.framework-6f2b763dc9c65ad86450ee6aec82da56d6c95617.zip
Bug 528422 - Cancel the resolve timeout task
Also properly name the framework event dispatcher thread to include the container UUID Change-Id: Ieb05540218708a2bb68d1f75ee78295f5f1decef Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java58
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java27
2 files changed, 71 insertions, 14 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
index 6861703da..e0c529f7c 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/container/ModuleResolver.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2016 IBM Corporation and others.
+ * Copyright (c) 2012, 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,10 +11,31 @@
package org.eclipse.osgi.container;
import java.security.Permission;
-import java.util.*;
-import java.util.concurrent.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CancellationException;
+import java.util.concurrent.Executor;
+import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.apache.felix.resolver.*;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.felix.resolver.Logger;
+import org.apache.felix.resolver.ResolutionError;
+import org.apache.felix.resolver.ResolverImpl;
import org.eclipse.osgi.container.ModuleRequirement.DynamicModuleRequirement;
import org.eclipse.osgi.container.namespaces.EquinoxFragmentNamespace;
import org.eclipse.osgi.internal.container.InternalUtils;
@@ -29,10 +50,24 @@ import org.eclipse.osgi.service.debug.DebugOptions;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
import org.osgi.framework.hooks.resolver.ResolverHook;
-import org.osgi.framework.namespace.*;
-import org.osgi.framework.wiring.*;
-import org.osgi.resource.*;
-import org.osgi.service.resolver.*;
+import org.osgi.framework.namespace.BundleNamespace;
+import org.osgi.framework.namespace.ExecutionEnvironmentNamespace;
+import org.osgi.framework.namespace.HostNamespace;
+import org.osgi.framework.namespace.IdentityNamespace;
+import org.osgi.framework.namespace.PackageNamespace;
+import org.osgi.framework.wiring.BundleCapability;
+import org.osgi.framework.wiring.BundleRequirement;
+import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.resource.Capability;
+import org.osgi.resource.Namespace;
+import org.osgi.resource.Requirement;
+import org.osgi.resource.Resource;
+import org.osgi.resource.Wire;
+import org.osgi.resource.Wiring;
+import org.osgi.service.resolver.HostedCapability;
+import org.osgi.service.resolver.ResolutionException;
+import org.osgi.service.resolver.ResolveContext;
+import org.osgi.service.resolver.Resolver;
/**
* The module resolver handles calls to the {@link Resolver} service for resolving modules
@@ -548,6 +583,7 @@ final class ModuleResolver {
private final Set<Resource> transitivelyResolveFailures = new LinkedHashSet<>();
private final Set<Resource> failedToResolve = new HashSet<>();
private AtomicBoolean scheduleTimeout = new AtomicBoolean(true);
+ private AtomicReference<ScheduledFuture<?>> timoutFuture = new AtomicReference<>();
/*
* Used to generate the UNRESOLVED_PROVIDER resolution report entries.
*
@@ -952,6 +988,10 @@ final class ModuleResolver {
} catch (ResolutionException e) {
re = e;
} finally {
+ ScheduledFuture<?> f = timoutFuture.getAndSet(null);
+ if (f != null) {
+ f.cancel(true);
+ }
computeUnresolvedProviderResolutionReportEntries(result);
computeUsesConstraintViolations(logger.getUsesConstraintViolations());
if (DEBUG_WIRING) {
@@ -1598,7 +1638,7 @@ final class ModuleResolver {
ScheduledExecutorService scheduledExecutor = adaptor.getScheduledExecutor();
if (scheduledExecutor != null) {
try {
- scheduledExecutor.schedule(callback, resolverBatchTimeout, TimeUnit.MILLISECONDS);
+ timoutFuture.set(scheduledExecutor.schedule(callback, resolverBatchTimeout, TimeUnit.MILLISECONDS));
} catch (RejectedExecutionException e) {
// ignore may have been shutdown, it is ok we will not be able to timeout
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java
index 9884a785a..2ab2e24ea 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/framework/EquinoxEventPublisher.java
@@ -12,13 +12,30 @@ package org.eclipse.osgi.internal.framework;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.*;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
-import org.eclipse.osgi.framework.eventmgr.*;
+import org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap;
+import org.eclipse.osgi.framework.eventmgr.EventDispatcher;
+import org.eclipse.osgi.framework.eventmgr.EventManager;
+import org.eclipse.osgi.framework.eventmgr.ListenerQueue;
import org.eclipse.osgi.internal.debug.Debug;
-import org.eclipse.osgi.internal.serviceregistry.*;
-import org.osgi.framework.*;
+import org.eclipse.osgi.internal.serviceregistry.HookContext;
+import org.eclipse.osgi.internal.serviceregistry.ServiceRegistry;
+import org.eclipse.osgi.internal.serviceregistry.ShrinkableCollection;
+import org.osgi.framework.AdminPermission;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.FrameworkEvent;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.SynchronousBundleListener;
import org.osgi.framework.hooks.bundle.CollisionHook;
import org.osgi.framework.hooks.bundle.EventHook;
@@ -59,7 +76,7 @@ public class EquinoxEventPublisher {
void init() {
// create our event manager on init()
- resetEventManager(new EventManager("Framework Event Dispatcher: " + toString())); //$NON-NLS-1$
+ resetEventManager(new EventManager("Framework Event Dispatcher: " + container.toString())); //$NON-NLS-1$
}
void close() {

Back to the top