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

Bug 337469

Summary: ConcurrentModificationException trying to search in the target platform preference page
Product: [Eclipse Project] PDE Reporter: Michael Rennie <Michael_Rennie>
Component: UIAssignee: Curtis Windatt <curtis.windatt.public>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ankur_sharma, curtis.windatt.public
Version: 3.7   
Target Milestone: 3.7 M6   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Michael Rennie CLA 2011-02-17 12:20:29 EST
Version: 3.7.0
Build id: I20110215-0800

64bit Windows + 64bit VM + 64bit Eclipse

Steps

1. Start Eclipse, navigate to the target platform preference page
2. open the default target platform for editing
3. go to the content tab
4. type 'my' in the search field - do not press enter or do anything

org.eclipse.swt.SWTException: Failed to execute runnable (java.util.ConcurrentModificationException)
at org.eclipse.swt.SWT.error(SWT.java:4210)
at org.eclipse.swt.SWT.error(SWT.java:4125)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:137)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4101)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3718)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferencePage.handleEdit(TargetPlatformPreferencePage.java:489)
at org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferencePage.access$4(TargetPlatformPreferencePage.java:483)
at org.eclipse.pde.internal.ui.preferences.TargetPlatformPreferencePage$4.doubleClick(TargetPlatformPreferencePage.java:260)
at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:824)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:822)
at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(StructuredViewer.java:1113)
at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1225)
at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:239)
at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:236)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:297)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4126)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3715)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.ui.internal.dialogs.WorkbenchPreferenceDialog.open(WorkbenchPreferenceDialog.java:215)
at org.eclipse.ui.internal.handlers.ShowPreferencePageHandler.execute(ShowPreferencePageHandler.java:54)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4126)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3715)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2700)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2664)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2498)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
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:344)
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:48)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:600)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.util.ConcurrentModificationException
at java.util.HashMap$AbstractMapIterator.checkConcurrentMod(HashMap.java:122)
at java.util.HashMap$AbstractMapIterator.makeNext(HashMap.java:127)
at java.util.HashMap$KeyIterator.next(HashMap.java:200)
at org.eclipse.pde.internal.ui.shared.CachedCheckboxTreeViewer.restoreLeafCheckState(CachedCheckboxTreeViewer.java:115)
at org.eclipse.pde.internal.ui.shared.FilteredCheckboxTree$2.run(FilteredCheckboxTree.java:100)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
... 59 more
Comment 1 Michael Rennie CLA 2011-02-22 11:51:48 EST
Had a chance to debug this, and it appears to only be reproducible on Win 7.

I found that in the CachedCheckboxTreeViewer the job to perform the filtering is modifying the checkstate set and the iterator taken below:

Iterator iter = checkState.iterator();
Object element = null;
if (iter.hasNext())
  expandAll();
while (iter.hasNext()) {
  element = iter.next();
  // Call the super class as there is no need to update the check state
  super.setChecked(element, true);
}

is now bogus after the call the expandAll().

You should probably change the Iterator to ListIterator or re-take the iterator after the call the expandAll().

The above snippet comes from CachedCheckboxTreeViewer#restoreLeafCheckState.
Comment 2 Michael Rennie CLA 2011-02-22 12:07:50 EST
should also change the code in CachedCheckboxTreeViewer to have a NO_ELEMENTS constant for the empty object array; there are many places in the code where empty arrays are created during tree item callbacks.
Comment 3 Curtis Windatt CLA 2011-02-22 14:58:27 EST
I was able to reproduce in Linux as well.

Fixed in HEAD.  See CachedCheckboxTreeViewer
Comment 4 Ankur Sharma CLA 2011-03-08 06:02:02 EST
Verified in I20110307-1300