Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Swanson2006-08-04 17:57:02 +0000
committerDarin Swanson2006-08-04 17:57:02 +0000
commit544e30f2fc22dde756a352a433e6b7952ad17376 (patch)
treeaf4703c6c26328a53be7f07686858261a1013c3a /org.eclipse.ui.console
parentc9f57bf4a36e12a76167041351516999afe10ef6 (diff)
downloadeclipse.platform.debug-544e30f2fc22dde756a352a433e6b7952ad17376.tar.gz
eclipse.platform.debug-544e30f2fc22dde756a352a433e6b7952ad17376.tar.xz
eclipse.platform.debug-544e30f2fc22dde756a352a433e6b7952ad17376.zip
Bug 152794 - ConcurrentModificationException disposing consoles from Ant UI test suite
Diffstat (limited to 'org.eclipse.ui.console')
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java41
1 files changed, 22 insertions, 19 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
index d5c6b5406..b4c0506db 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/console/IOConsole.java
@@ -13,7 +13,6 @@ package org.eclipse.ui.console;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -83,7 +82,10 @@ public class IOConsole extends TextConsole {
}
openStreams = new ArrayList();
inputStream = new IOConsoleInputStream(this);
- openStreams.add(inputStream);
+ synchronized (openStreams) {
+ openStreams.add(inputStream);
+ }
+
partitioner = new IOConsolePartitioner(inputStream, this);
partitioner.connect(getDocument());
}
@@ -246,23 +248,24 @@ public class IOConsole extends TextConsole {
protected void dispose() {
super.dispose();
partitioner.disconnect();
- synchronized (openStreams) {
- Iterator iterator = openStreams.iterator();
- while (iterator.hasNext()) {
- Object stream = iterator.next();
- if (stream instanceof IOConsoleInputStream) {
- IOConsoleInputStream is = (IOConsoleInputStream) stream;
- try {
- is.close();
- } catch (IOException e) {
- }
- } else if (stream instanceof IOConsoleOutputStream) {
- IOConsoleOutputStream os = (IOConsoleOutputStream) stream;
- try {
- os.close();
- } catch (IOException e) {
- }
- }
+ //make a copy of the open streams and close them all
+ //a copy is needed as close the streams results in a callback that
+ //removes the streams from the openStreams collection (bug 152794)
+ Object[] allStreams= openStreams.toArray();
+ for (int i = 0; i < allStreams.length; i++) {
+ Object stream = allStreams[i];
+ if (stream instanceof IOConsoleInputStream) {
+ IOConsoleInputStream is = (IOConsoleInputStream) stream;
+ try {
+ is.close();
+ } catch (IOException e) {
+ }
+ } else if (stream instanceof IOConsoleOutputStream) {
+ IOConsoleOutputStream os = (IOConsoleOutputStream) stream;
+ try {
+ os.close();
+ } catch (IOException e) {
+ }
}
}
inputStream = null;

Back to the top