Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBJ Hargrave2008-07-16 10:15:58 -0400
committerBJ Hargrave2008-07-16 10:15:58 -0400
commit10f3183ebb2f92c21a014171f1d1820b9df8ecda (patch)
tree6ee463221757bcce0bc2d58143a2aadadb46852d /bundles
parentf6360e2e40c4b0c77d16caf8eeb8a82a335d2a05 (diff)
downloadrt.equinox.framework-10f3183ebb2f92c21a014171f1d1820b9df8ecda.tar.gz
rt.equinox.framework-10f3183ebb2f92c21a014171f1d1820b9df8ecda.tar.xz
rt.equinox.framework-10f3183ebb2f92c21a014171f1d1820b9df8ecda.zip
bug 240702 - fix to prevent (re)creation of EventThread after the EventManager has been closed.
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/eventmgr/EventManager.java15
-rw-r--r--bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java15
2 files changed, 30 insertions, 0 deletions
diff --git a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/eventmgr/EventManager.java b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/eventmgr/EventManager.java
index 0b605e5be..3f9c114f8 100644
--- a/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/eventmgr/EventManager.java
+++ b/bundles/org.eclipse.osgi/core/framework/org/eclipse/osgi/framework/eventmgr/EventManager.java
@@ -106,6 +106,12 @@ public class EventManager {
*/
private EventThread thread;
+ /**
+ * Once closed, an attempt to create a new EventThread will result in an
+ * IllegalStateException.
+ */
+ private boolean closed;
+
/**
* Thread name used for asynchronous event delivery
*/
@@ -148,6 +154,7 @@ public class EventManager {
*/
public EventManager(String threadName, ThreadGroup threadGroup) {
thread = null;
+ closed = false;
this.threadName = threadName;
this.threadGroup = threadGroup;
}
@@ -161,10 +168,14 @@ public class EventManager {
* thread terminates.
*/
public synchronized void close() {
+ if (closed) {
+ return;
+ }
if (thread != null) {
thread.close();
thread = null;
}
+ closed = true;
}
/**
@@ -175,6 +186,9 @@ public class EventManager {
* this EventManager.
*/
synchronized EventThread getEventThread() {
+ if (closed) {
+ throw new IllegalStateException();
+ }
if (thread == null) {
/* if there is no thread, then create a new one */
thread = new EventThread(threadGroup, threadName);
@@ -376,6 +390,7 @@ public class EventManager {
try {
wait();
} catch (InterruptedException e) {
+ // If interrupted, we will loop back up and check running
}
}
diff --git a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java
index 0b605e5be..3f9c114f8 100644
--- a/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java
+++ b/bundles/org.eclipse.osgi/supplement/src/org/eclipse/osgi/framework/eventmgr/EventManager.java
@@ -106,6 +106,12 @@ public class EventManager {
*/
private EventThread thread;
+ /**
+ * Once closed, an attempt to create a new EventThread will result in an
+ * IllegalStateException.
+ */
+ private boolean closed;
+
/**
* Thread name used for asynchronous event delivery
*/
@@ -148,6 +154,7 @@ public class EventManager {
*/
public EventManager(String threadName, ThreadGroup threadGroup) {
thread = null;
+ closed = false;
this.threadName = threadName;
this.threadGroup = threadGroup;
}
@@ -161,10 +168,14 @@ public class EventManager {
* thread terminates.
*/
public synchronized void close() {
+ if (closed) {
+ return;
+ }
if (thread != null) {
thread.close();
thread = null;
}
+ closed = true;
}
/**
@@ -175,6 +186,9 @@ public class EventManager {
* this EventManager.
*/
synchronized EventThread getEventThread() {
+ if (closed) {
+ throw new IllegalStateException();
+ }
if (thread == null) {
/* if there is no thread, then create a new one */
thread = new EventThread(threadGroup, threadName);
@@ -376,6 +390,7 @@ public class EventManager {
try {
wait();
} catch (InterruptedException e) {
+ // If interrupted, we will loop back up and check running
}
}

Back to the top