Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2008-11-04 23:35:28 +0000
committerSimon Kaegi2008-11-04 23:35:28 +0000
commit410b2a173524edde3de95f7d074cf14b66ffc93c (patch)
tree0ae4ebc3e4c06ca6799bffca01dc21ca91410a5b
parent60aed4facdb0d3f30a770e242bf3adce763638b9 (diff)
downloadrt.equinox.p2-410b2a173524edde3de95f7d074cf14b66ffc93c.tar.gz
rt.equinox.p2-410b2a173524edde3de95f7d074cf14b66ffc93c.tar.xz
rt.equinox.p2-410b2a173524edde3de95f7d074cf14b66ffc93c.zip
Bug 253794 p2 parser error - XML document structures must start and end within the same entityv20081104-1843R34x_v20081104
-rw-r--r--bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java43
1 files changed, 41 insertions, 2 deletions
diff --git a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java
index 08ff80ed0..6f7becf70 100644
--- a/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java
+++ b/bundles/org.eclipse.equinox.p2.core/src/org/eclipse/equinox/internal/p2/core/ProvisioningEventBus.java
@@ -22,6 +22,12 @@ public class ProvisioningEventBus implements EventDispatcher, IProvisioningEvent
private EventListeners asyncListeners = new EventListeners();
private EventManager eventManager = new EventManager("Provisioning Event Dispatcher"); //$NON-NLS-1$
+ private Object dispatchEventLock = new Object();
+ /* @GuardedBy("dispatchEventLock") */
+ private boolean closed = false;
+ /* @GuardedBy("dispatchEventLock") */
+ private int dispatchingEvents = 0;
+
/* (non-Javadoc)
* @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#addListener(org.eclipse.equinox.internal.provisional.p2.core.eventbus.ProvisioningListener)
*/
@@ -60,6 +66,10 @@ public class ProvisioningEventBus implements EventDispatcher, IProvisioningEvent
* @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#publishEvent(java.util.EventObject)
*/
public void publishEvent(EventObject event) {
+ synchronized (dispatchEventLock) {
+ if (closed)
+ return;
+ }
/* queue to hold set of listeners */
ListenerQueue listeners = new ListenerQueue(eventManager);
@@ -74,7 +84,10 @@ public class ProvisioningEventBus implements EventDispatcher, IProvisioningEvent
listeners = new ListenerQueue(eventManager);
synchronized (asyncListeners) {
listeners.queueListeners(asyncListeners, this);
- listeners.dispatchEventAsynchronous(0, event);
+ synchronized (dispatchEventLock) {
+ if (!closed)
+ listeners.dispatchEventAsynchronous(0, event);
+ }
}
}
@@ -82,11 +95,22 @@ public class ProvisioningEventBus implements EventDispatcher, IProvisioningEvent
* @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#dispatchEvent(java.lang.Object, java.lang.Object, int, java.lang.Object)
*/
public void dispatchEvent(Object eventListener, Object listenerObject, int eventAction, Object eventObject) {
+ synchronized (dispatchEventLock) {
+ if (closed)
+ return;
+ dispatchingEvents++;
+ }
try {
((ProvisioningListener) eventListener).notify((EventObject) eventObject);
} catch (Exception e) {
e.printStackTrace();
//TODO Need to do the appropriate logging
+ } finally {
+ synchronized (dispatchEventLock) {
+ dispatchingEvents--;
+ if (dispatchingEvents == 0)
+ dispatchEventLock.notifyAll();
+ }
}
}
@@ -94,6 +118,21 @@ public class ProvisioningEventBus implements EventDispatcher, IProvisioningEvent
* @see org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus#close()
*/
public void close() {
- eventManager.close();
+ boolean interrupted = false;
+ synchronized (dispatchEventLock) {
+ eventManager.close();
+ closed = true;
+ while (dispatchingEvents != 0) {
+ try {
+ dispatchEventLock.wait(30000); // we're going to cap waiting time at 30s
+ break;
+ } catch (InterruptedException e) {
+ // keep waiting but flag interrupted
+ interrupted = true;
+ }
+ }
+ }
+ if (interrupted)
+ Thread.currentThread().interrupt();
}
}

Back to the top