Bug 558688 - [JFace] Concurrent modification exception when adding category.xml categories
Summary: [JFace] Concurrent modification exception when adding category.xml categories
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.14   Edit
Hardware: PC All
: P3 major (vote)
Target Milestone: 4.15 M1   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2019-12-30 10:39 EST by Wim Jongman CLA
Modified: 2020-01-10 14:07 EST (History)
4 users (show)

See Also:


Attachments
stacktrace (3.64 KB, text/plain)
2019-12-30 10:39 EST, Wim Jongman CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wim Jongman CLA 2019-12-30 10:39:13 EST
Created attachment 281355 [details]
stacktrace

When creating a new category in the category.xml editor this exception was seen multiple times.
Comment 1 Andrey Loskutov CLA 2019-12-30 13:06:27 EST
java.util.ConcurrentModificationException
	at java.util.Vector$Itr.checkForComodification(Vector.java:1210)
	at java.util.Vector$Itr.next(Vector.java:1163)
	at org.eclipse.ui.forms.ManagedForm.fireSelectionChanged(ManagedForm.java:123)
	at org.eclipse.pde.internal.ui.editor.TreeSection$PartAdapter.selectionChanged(TreeSection.java:36)
	at org.eclipse.pde.internal.ui.parts.TreePart.lambda$0(TreePart.java:44)
	at org.eclipse.jface.viewers.Viewer$1.run(Viewer.java:151)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.ui.internal.JFaceUtil.lambda$0(JFaceUtil.java:47)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:174)
	at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java:148)
	at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:2129)
	at org.eclipse.jface.viewers.StructuredViewer.setSelection(StructuredViewer.java:1659)
	at org.eclipse.jface.viewers.TreeViewer.setSelection(TreeViewer.java:1084)
	at org.eclipse.pde.internal.ui.editor.category.CategorySection.handleAddCategoryDefinition(CategorySection.java:527)

Simeon, can you please check if this is again a side effect of our favourite optimization?
See bug 558510 etc.
Comment 2 Andrey Loskutov CLA 2020-01-06 16:05:41 EST
(In reply to Andrey Loskutov from comment #1) 
> Simeon, can you please check if this is again a side effect of our favourite
> optimization?
> See bug 558510 etc.

For sure it is. Regression from https://git.eclipse.org/r/#/c/152807/. Same pattern as before, the listener notification code was buggy but "tolerated" re-entering the loop, now it is just buggy.
Comment 3 Andrey Loskutov CLA 2020-01-06 17:31:42 EST
Here is how the parts vector gets changed dujring iteration over it:

Thread [main] (Suspended (breakpoint at line 82 in ManagedForm))	
	FormPage$PageForm(ManagedForm).addPart(IFormPart) line: 82	
	IUsPage$1(PDEDetailsSections).createContents(Composite) line: 35	
	DetailsPart.lambda$0(Object, IDetailsPage, IDetailsPage) line: 261	
	494474405.run() line: not available	
	BusyIndicator.showWhile(Display, Runnable) line: 72	
	DetailsPart.showPage(Object) line: 258	
	DetailsPart.update() line: 231	
	DetailsPart.selectionChanged(IFormPart, ISelection) line: 216	
	FormPage$PageForm(ManagedForm).fireSelectionChanged(IFormPart, ISelection) line: 127	
	TreeSection$PartAdapter.selectionChanged(IStructuredSelection) line: 36	
	TreeSection$PartAdapter(TreePart).lambda$0(SelectionChangedEvent) line: 44	
	1903906274.selectionChanged(SelectionChangedEvent) line: not available	
	Viewer$1.run() line: 151	
	SafeRunner$1.runWithResult() line: 47	
	SafeRunner$1.runWithResult() line: 1	
	SafeRunner.run(ISafeRunnableWithResult<T>) line: 77	
	SafeRunner.run(ISafeRunnable) line: 43	
	JFaceUtil.lambda$0(ISafeRunnable) line: 47	
	1920098017.run(ISafeRunnable) line: not available	
	SafeRunnable.run(ISafeRunnable) line: 174	
	TreeViewer(Viewer).fireSelectionChanged(SelectionChangedEvent) line: 148	
	TreeViewer(StructuredViewer).updateSelection(ISelection) line: 2129	
	TreeViewer(StructuredViewer).setSelection(ISelection, boolean) line: 1659	
	TreeViewer.setSelection(ISelection, boolean) line: 1084	
	CategorySection.handleAddCategoryDefinition() line: 527	
	CategorySection.buttonSelected(int) line: 471	
	TreeSection$PartAdapter.buttonSelected(Button, int) line: 47	
	SharedPartWithButtons$SelectionHandler.buttonSelected(SelectionEvent) line: 47	
	SharedPartWithButtons$SelectionHandler.widgetSelected(SelectionEvent) line: 37	
	TypedListener.handleEvent(Event) line: 252	
	EventTable.sendEvent(Event) line: 89	
	Display.sendEvent(EventTable, Event) line: 4163	

The actual code was not nice, but it wasn't *that* buggy, because added part was at the end of the list.
I will revert the olriginal change for M1.
Comment 4 Eclipse Genie CLA 2020-01-06 17:38:47 EST
New Gerrit change created: https://git.eclipse.org/r/155341
Comment 6 Andrey Loskutov CLA 2020-01-06 17:59:35 EST
@Carsten: as usually, please create a new bug report for the ManagedForm.fireSelectionChanged iteration problem, this should be investigated & ideally a test should be added to the proposed fix of the original problem.
Comment 7 Simeon Andreev CLA 2020-01-07 01:11:46 EST
> Simeon, can you please check if this is again a side effect of our favourite
> optimization?
> See bug 558510 etc.

Sorry, just noticed your question. Probably I didn't read past the stack trace in the initial notification.
Comment 8 Andrey Loskutov CLA 2020-01-07 05:20:02 EST
Verified with build I20200106-1805.
Comment 9 Wim Jongman CLA 2020-01-07 06:01:20 EST
(In reply to Andrey Loskutov from comment #8)
> Verified with build I20200106-1805.

Andrey, thanks for taken care of this.
Comment 10 Carsten Hammer CLA 2020-01-07 17:28:59 EST
(In reply to Andrey Loskutov from comment #6)
> @Carsten: as usually, please create a new bug report for the
> ManagedForm.fireSelectionChanged iteration problem, this should be
> investigated & ideally a test should be added to the proposed fix of the
> original problem.

Yes, I will do - thanks for taking care!
Comment 11 Carsten Hammer CLA 2020-01-10 14:07:12 EST
(In reply to Andrey Loskutov from comment #6)
> @Carsten: as usually, please create a new bug report for the
> ManagedForm.fireSelectionChanged iteration problem, this should be
> investigated & ideally a test should be added to the proposed fix of the
> original problem.

created https://bugs.eclipse.org/bugs/show_bug.cgi?id=559046