Bug 562314 - "IllegalArgumentException: Comparison method violates its general contract" error in DetailedProgressViewer
Summary: "IllegalArgumentException: Comparison method violates its general contract" e...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.16 M3   Edit
Assignee: Andrey Loskutov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-20 07:37 EDT by Andrey Loskutov CLA
Modified: 2020-04-22 08:09 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 Andrey Loskutov CLA 2020-04-20 07:37:02 EDT
Following error was reported in our automated tests based on 4.15 platform, during some wizard operations, in BlockedJobsDialog:

java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeHi(TimSort.java:899)
	at java.util.TimSort.mergeAt(TimSort.java:516)
	at java.util.TimSort.mergeForceCollapse(TimSort.java:457)
	at java.util.TimSort.sort(TimSort.java:254)
	at java.util.Arrays.sort(Arrays.java:1438)
	at org.eclipse.jface.viewers.ViewerComparator.sort(ViewerComparator.java:206)
	at org.eclipse.ui.internal.progress.DetailedProgressViewer.add(DetailedProgressViewer.java:180)
	at org.eclipse.ui.internal.progress.ProgressViewerContentProvider.add(ProgressViewerContentProvider.java:138)
	at org.eclipse.ui.internal.progress.ProgressViewUpdater.update(ProgressViewUpdater.java:308)
	at org.eclipse.jface.util.Throttler.lambda$1(Throttler.java:62)
	at org.eclipse.swt.widgets.Display.timerProc(Display.java:5590)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4446)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.block(ModalContext.java:166)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:368)
	at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1033)

As my co-worker properly identified, the problem is that JobTreeElement entries managed by  DetailedProgressViewer are inherently unsafe for sorting purposes (they change the state constantly), so *everyone* using DetailedProgressViewer should set a comparator that is "safe" for errors reported by TimSort, like ProgressManagerUtil.getProgressViewerComparator().

See bug 361121 / bug 371354 comment 8.

We see that ProgressView uses the "fixed" comparator, but both ProgressMonitorJobsDialog and BlockedJobsDialog doesn't.

I will push a patch in a moment.
Comment 1 Eclipse Genie CLA 2020-04-20 07:52:41 EDT
New Gerrit change created: https://git.eclipse.org/r/161228