Bug 282563. [ds] RCP using declarative services (occasionally) hangs for 30 secs on start-up
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java
index 233bcfb..e456995 100644
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java
+++ b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/SCRManager.java
@@ -629,19 +629,24 @@
}
// store the components in the cache
bundleToServiceComponents.put(bundle, components.clone());
- // this will also resolve the component dependencies!
- enqueueWork(this, ENABLE_COMPONENTS, components, false);
- synchronized (components) {
- long startTime = System.currentTimeMillis();
- try {
- do {
- components.wait(1000);
- } while (!components.isEmpty() && (System.currentTimeMillis() - startTime < WorkThread.BLOCK_TIMEOUT));
- if (System.currentTimeMillis() - startTime >= WorkThread.BLOCK_TIMEOUT) {
- Activator.log.warning(NLS.bind(Messages.TIMEOUT_REACHED_ENABLING_COMPONENTS, getBundleName(bundle), Integer.toString(WorkThread.BLOCK_TIMEOUT)), null);
+ if (workThread != null && workThread.processingThread == Thread.currentThread()) {
+ //we are in the queue thread already. Processing synchronously the job
+ resolver.enableComponents(components);
+ } else {
+ // this will also resolve the component dependencies!
+ enqueueWork(this, ENABLE_COMPONENTS, components, false);
+ synchronized (components) {
+ long startTime = System.currentTimeMillis();
+ try {
+ do {
+ components.wait(1000);
+ } while (!components.isEmpty() && (System.currentTimeMillis() - startTime < WorkThread.BLOCK_TIMEOUT));
+ if (System.currentTimeMillis() - startTime >= WorkThread.BLOCK_TIMEOUT) {
+ Activator.log.warning(NLS.bind(Messages.TIMEOUT_REACHED_ENABLING_COMPONENTS, getBundleName(bundle), Integer.toString(WorkThread.BLOCK_TIMEOUT)), null);
+ }
+ } catch (InterruptedException e) {
+ //do nothing
}
- } catch (InterruptedException e) {
- //do nothing
}
}
}
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/WorkThread.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/WorkThread.java
index 56ddc03..7ae2b1d 100644
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/WorkThread.java
+++ b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/WorkThread.java
@@ -31,6 +31,7 @@
private SCRManager mgr;
private Object objectToProcess;
boolean running = true;
+ Thread processingThread;
int waiting = 0;
@@ -43,6 +44,7 @@
* ManagedService(Factories) are informed for the event.
*/
public void run() {
+ processingThread = Thread.currentThread();
do {
try {
Queue queue = mgr.queue;
@@ -97,6 +99,7 @@
}
} while (running);
objectToProcess = null;
+ processingThread = null;
}
public void timer(int event) {