Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarin Wright2009-01-28 21:51:31 +0000
committerDarin Wright2009-01-28 21:51:31 +0000
commit7a3ff2b25a990f089c997e890c3681d370b6a45d (patch)
tree747b60df164fb426c43d19f52d22325fa9ccc621
parent3b992fa981de141db5fcbe17bd71877a784e6e9a (diff)
downloadeclipse.platform.debug-7a3ff2b25a990f089c997e890c3681d370b6a45d.tar.gz
eclipse.platform.debug-7a3ff2b25a990f089c997e890c3681d370b6a45d.tar.xz
eclipse.platform.debug-7a3ff2b25a990f089c997e890c3681d370b6a45d.zip
[r342] Bug 259107 - [console] Console Deadlock when too much information written
-rw-r--r--org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java113
1 files changed, 65 insertions, 48 deletions
diff --git a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
index 18c62bac9..5404474f6 100644
--- a/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
+++ b/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/IOConsolePartitioner.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2009 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
@@ -29,6 +29,7 @@ import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.ConsolePlugin;
import org.eclipse.ui.console.IConsoleDocumentPartitioner;
import org.eclipse.ui.console.IOConsole;
@@ -458,11 +459,19 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
}
}
- if (fBuffer > 160000) {
- try {
- pendingPartitions.wait();
- } catch (InterruptedException e) {
- }
+ if (fBuffer > 160000) {
+ if(Display.getCurrent() == null){
+ try {
+ pendingPartitions.wait();
+ } catch (InterruptedException e) {
+ }
+ } else {
+ /*
+ * if we are in UI thread we cannot lock it, so process
+ * queued output.
+ */
+ processQueue();
+ }
}
}
}
@@ -502,47 +511,7 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
* @see org.eclipse.core.internal.jobs.InternalJob#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public IStatus runInUIThread(IProgressMonitor monitor) {
- synchronized (overflowLock) {
- ArrayList pendingCopy = new ArrayList();
- StringBuffer buffer = null;
- boolean consoleClosed = false;
- while (pendingPartitions.size() > 0) {
- synchronized(pendingPartitions) {
- pendingCopy.addAll(pendingPartitions);
- pendingPartitions.clear();
- fBuffer = 0;
- pendingPartitions.notifyAll();
- }
-
- buffer = new StringBuffer();
- for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) {
- PendingPartition pp = (PendingPartition) i.next();
- if (pp != consoleClosedPartition) {
- buffer.append(pp.text);
- } else {
- consoleClosed = true;
- }
- }
- }
-
- if (connected) {
- setUpdateInProgress(true);
- updatePartitions = pendingCopy;
- firstOffset = document.getLength();
- try {
- document.replace(firstOffset, 0, buffer.toString());
- } catch (BadLocationException e) {
- }
- updatePartitions = null;
- setUpdateInProgress(false);
- }
- if (consoleClosed) {
- console.partitionerFinished();
- }
- checkBufferSize();
-
- }
-
+ processQueue();
return Status.OK_STATUS;
}
@@ -560,7 +529,55 @@ public class IOConsolePartitioner implements IConsoleDocumentPartitioner, IDocum
}
-
+ void processQueue() {
+ synchronized (overflowLock) {
+ ArrayList pendingCopy = new ArrayList();
+ StringBuffer buffer = null;
+ boolean consoleClosed = false;
+ while (pendingPartitions.size() > 0) {
+ synchronized(pendingPartitions) {
+ pendingCopy.addAll(pendingPartitions);
+ pendingPartitions.clear();
+ fBuffer = 0;
+ pendingPartitions.notifyAll();
+ }
+ // determine buffer size
+ int size = 0;
+ for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) {
+ PendingPartition pp = (PendingPartition) i.next();
+ if (pp != consoleClosedPartition) {
+ size+= pp.text.length();
+ }
+ }
+ buffer = new StringBuffer(size);
+ for (Iterator i = pendingCopy.iterator(); i.hasNext(); ) {
+ PendingPartition pp = (PendingPartition) i.next();
+ if (pp != consoleClosedPartition) {
+ buffer.append(pp.text);
+ } else {
+ consoleClosed = true;
+ }
+ }
+ }
+
+ if (connected) {
+ setUpdateInProgress(true);
+ updatePartitions = pendingCopy;
+ firstOffset = document.getLength();
+ try {
+ document.replace(firstOffset, 0, buffer.toString());
+ } catch (BadLocationException e) {
+ }
+ updatePartitions = null;
+ setUpdateInProgress(false);
+ }
+ if (consoleClosed) {
+ console.partitionerFinished();
+ }
+ checkBufferSize();
+ }
+
+ }

Back to the top