Bug 138785 - [Workbench] ArrayIndexOutOfBounds in WorkbenchPage.ActivationList#bringToTop
Summary: [Workbench] ArrayIndexOutOfBounds in WorkbenchPage.ActivationList#bringToTop
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.2 RC2   Edit
Assignee: Tod Creasey CLA
QA Contact:
URL:
Whiteboard:
Keywords: greatbug
Depends on:
Blocks:
 
Reported: 2006-04-26 18:38 EDT by John Arthorne CLA
Modified: 2006-04-28 10:03 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2006-04-26 18:38:26 EDT
I got this AIOOBE when running the UI test suites against HEAD.  The problem is in this line:

int newIndex = lastIndexOfContainer(targetContainer);
if (ref == parts.get(newIndex)) {

The method lastIndexOfContainer can return -1, in which case you'll get the AIIOBE on the next line.

java.lang.ArrayIndexOutOfBoundsException
	at java.util.ArrayList.get(ArrayList.java:358)
	at org.eclipse.ui.internal.WorkbenchPage$ActivationList.bringToTop(WorkbenchPage.java:3814)
	at org.eclipse.ui.internal.WorkbenchPage.updateVisibility(WorkbenchPage.java:3300)
	at org.eclipse.ui.internal.WorkbenchPage.setPerspective(WorkbenchPage.java:3222)
	at org.eclipse.ui.internal.WorkbenchPage.busySetPerspective(WorkbenchPage.java:957)
	at org.eclipse.ui.internal.WorkbenchPage.access$12(WorkbenchPage.java:941)
	at org.eclipse.ui.internal.WorkbenchPage$12.run(WorkbenchPage.java:3340)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchPage.setPerspective(WorkbenchPage.java:3338)
	at org.eclipse.ui.tests.api.IWorkbenchPageTest.testBug76285(IWorkbenchPageTest.java:2005)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
	at java.lang.reflect.Method.invoke(Method.java:391)
	at junit.framework.TestCase.runTest(TestCase.java:154)
	at junit.framework.TestCase.runBare(TestCase.java:127)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:118)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at junit.framework.TestSuite.runTest(TestSuite.java:208)
	at junit.framework.TestSuite.run(TestSuite.java:203)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:481)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:347)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:57)
	at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.run(UITestApplication.java:105)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:123)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3325)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2971)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:143)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
	at org.eclipse.pde.internal.junit.runtime.UITestApplication.run(UITestApplication.java:45)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
	at java.lang.reflect.Method.invoke(Method.java:391)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)
Comment 1 Tod Creasey CLA 2006-04-27 10:28:26 EDT
The code should read

//New index can be -1 if there is no last index
            if (newIndex >= 0 && ref == parts.get(newIndex)) 
				return;
			
            parts.remove(ref);
            if(newIndex >= 0)
            	parts.add(newIndex, ref);
            else
            	parts.add(ref);

McQ we should add this for RC2
Comment 2 Tod Creasey CLA 2006-04-27 10:36:32 EDT
great bug as usual John - thanks!
Comment 3 Mike Wilson CLA 2006-04-27 10:52:28 EDT
+1.

Comment 4 Tod Creasey CLA 2006-04-27 11:11:18 EDT
Fixed for 20060425-1200
Comment 5 Tod Creasey CLA 2006-04-28 09:58:55 EDT
Marking verified for 20060428-0010 by code inspection
Comment 6 John Arthorne CLA 2006-04-28 10:03:36 EDT
I can also verify this - I reran the test, which was previously consistently getting the error, and it now passes.