Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 250306

Summary: [console] IOOBE pasting multiple lines into IOConsole after clearing console
Product: [Eclipse Project] Platform Reporter: Dan Heidinga <heidinga>
Component: DebugAssignee: Paul Pazderski <paul-eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: paul-eclipse, pawel.1.piech, sarika.sinha
Version: 3.4   
Target Milestone: 4.13 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on: 548356    
Bug Blocks: 552030    
Attachments:
Description Flags
One line fix for IOOBE none

Description Dan Heidinga CLA 2008-10-09 11:33:24 EDT
Build ID:  I20080617-2000

Steps To Reproduce:
1.  Paste multiple lines into the IOConsole.
2.  Clear the console.
3.  Paste the multiple lines in again.


More information:
After the IndexOutOfBoundsException, moving the mouse into the console will also cause multiple IllegalArgumentExceptions from  org.eclipse.swt.custom.StyledText.setCaretOffset(StyledText.java:6867).

It appears the partition we are looking for in the partitions ArrayList no longer exists.  We then try to insert at position -1.

Stacktrace:
java.lang.IndexOutOfBoundsException
	at java.util.ArrayList.add(Unknown Source)
	at org.eclipse.ui.internal.console.IOConsolePartitioner.documentChanged2(IOConsolePartitioner.java:413)
	at org.eclipse.jface.text.AbstractDocument.updateDocumentStructures(AbstractDocument.java:672)
	at org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:759)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1157)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1176)
	at org.eclipse.ui.internal.console.ConsoleDocument.replace(ConsoleDocument.java:82)
	at org.eclipse.ui.internal.console.ConsoleDocumentAdapter.replaceTextRange(ConsoleDocumentAdapter.java:258)
	at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:5876)
	at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:6631)
	at org.eclipse.swt.custom.StyledText.doContent(StyledText.java:2186)
	at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5145)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5170)
	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:4873)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1003)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1027)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1012)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1040)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1036)
	at org.eclipse.swt.widgets.Widget.wmChar(Widget.java:1352)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3894)
	at org.eclipse.swt.widgets.Canvas.WM_CHAR(Canvas.java:341)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:3787)
	at org.eclipse.swt.widgets.Canvas.windowProc(Canvas.java:337)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4528)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:2370)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3420)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2382)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2346)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2198)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:493)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:288)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:488)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:193)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:612)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:549)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1236)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1212)
Comment 1 Dan Heidinga CLA 2008-10-09 11:35:53 EDT
Created attachment 114694 [details]
One line fix for IOOBE

This checks if the index is -1 and then doesn't attempt to add the partition.  Very basic testing seems to indicate that this corrects the problem.  ie: I still see all the text I expect to see in the console.
Comment 2 Kevin McGuire CLA 2008-10-20 15:43:42 EDT
Another re-emergence of bug #176508?
See also #249878 which this may be a duplicate of.
Comment 3 Pawel Piech CLA 2011-06-03 18:53:30 EDT
If this is still a problem, please reopen.
Comment 4 Sarika Sinha CLA 2015-09-09 02:59:50 EDT
Occuring many times as reported by error reporting tool.
Comment 5 Paul Pazderski CLA 2019-06-17 15:49:15 EDT
Cannot reproduce using the original steps but with:
 1. type some text in console (not pressing enter)
 2. let program produce some output
 3. clear console
 4. press enter

The problem should be fixed with bug 548356.
Comment 6 Paul Pazderski CLA 2019-07-10 11:32:43 EDT
Verified with I20190709-1800