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

Bug 364735

Summary: [Viewers] ViewerComparator violates its general contract
Product: [Eclipse Project] Platform Reporter: Mark A. Ziesemer <bugs>
Component: UIAssignee: Andrey Loskutov <loskutov>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: bsd, bugs, daniel_megert, david_williams, heiko.boettger, jacob, john.arthorne, Lars.Vogel, loskutov, nitram509, pascal, peblpebl, psuzzi, pwebster, remy.suen, sayresVT, stephane, vvictorion, zds
Version: 4.2Keywords: noteworthy
Target Milestone: 4.6.2Flags: bsd: review+
Hardware: All   
OS: All   
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=371586
https://bugs.eclipse.org/bugs/show_bug.cgi?id=403533
https://git.eclipse.org/r/80327
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=7defd6d25ecbb5f3e4c88ba228056cdff3b53677
https://git.eclipse.org/r/80630
https://git.eclipse.org/r/80675
https://git.eclipse.org/c/www.eclipse.org/eclipse/news.git/commit/?id=1ea2be537ba02a301b4678fca328e31baf1ea46b
https://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=a52c18ef6403a88c3e4d926503ae67b301858c98
https://bugs.eclipse.org/bugs/show_bug.cgi?id=512637
Whiteboard:
Bug Depends on:    
Bug Blocks: 403533, 501057    
Attachments:
Description Flags
Stack trace.
none
WST Error Details
none
jface Error Details
none
Blind guess patch, fixing integer overflow in ViewerComperator, including pre-compiled JAR
none
Logging of state at the time of the exception
none
Subclipse Error Details
none
Stack Trace from Error Log.
none
"Workaround for comparator violation" from Error Log.
none
error log on "create new file" none

Description Mark A. Ziesemer CLA 2011-11-24 11:57:19 EST
Build Identifier: M20110909-1335

Using Java 1.7.0_01 (x64).  Seems very similar to Bug 317785, but unrelated to Equinox - and I'm already on Eclipse 3.7.1.

Reproducible: Sometimes

Steps to Reproduce:
Right-click on any package or folder from either the "Package Explorer" or "Navigator" views, expand "New", then choose something to create.  (Seems to affect any artifact type, but I've noticed this the most often for creating a new "Folder" and "File".)  The dialog to prompt for the new name and any other details never appears.  Examining the Eclipse error log yields the attached stack trace, the most significant lines being:

java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeHi(TimSort.java:868)
	at java.util.TimSort.mergeAt(TimSort.java:485)
	at java.util.TimSort.mergeCollapse(TimSort.java:410)
	at java.util.TimSort.sort(TimSort.java:214)
	at java.util.TimSort.sort(TimSort.java:173)
	at java.util.Arrays.sort(Arrays.java:659)
	at org.eclipse.jface.viewers.ViewerComparator.sort(ViewerComparator.java:185)
	at org.eclipse.jface.viewers.AbstractTreeViewer.getSortedChildren(AbstractTreeViewer.java:628)

Adding -Djava.util.Arrays.useLegacyMergeSort=true to my eclipse.ini does seem to have resolved the issue.
Comment 1 Mark A. Ziesemer CLA 2011-11-24 11:58:32 EST
Created attachment 207491 [details]
Stack trace.
Comment 2 Pascal Rapicault CLA 2011-11-26 09:15:31 EST
As mentioned by Mark, see discussion in bug #317785. These sorts of errors caused by a problem in the comparator (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=317785#c20)
Comment 3 Martin W. Kirst CLA 2011-11-26 14:26:21 EST
Hi,

it's hard for me to reproduce.
Would you please give some details about the Eclipse package you're using?

I've already tried "Eclipse IDE for Java Developers", Indigo SR1 + JRE 1.7.0_01
without any errors :-/

Regards
 Martin
Comment 4 Mark A. Ziesemer CLA 2011-11-26 14:31:47 EST
(In reply to comment #3)
> it's hard for me to reproduce.

Yes, unfortunately, I can't reproduce at-will either - but once I get into a situation where the dialogs don't appear, it seems that I can't get them back until I restart Eclipse.

> Would you please give some details about the Eclipse package you're using?
> 
> I've already tried "Eclipse IDE for Java Developers", Indigo SR1 + JRE 1.7.0_01
> without any errors :-/

I'm actually using "Eclipse IDE for Java EE Developers", Indigo SR1 + JRE 1.7.0_01.
Comment 5 Martin W. Kirst CLA 2011-11-26 15:36:11 EST
Hi,

thanks for the details.
Do you have any additional plugins installed - or just plain Eclipse JEE from Download?

I've investigated some debugging and it seems to me, that the error
raises, when there is an 'New file' or 'New folder' dialog.
Such a dialog requests a project resources tree view. Afterwards,
within the jface.TreeViewer the exceptions occurs.
At the moment I assume, that there is something "special" regarding
your project layout.
I hope, we can narrow down the problem by eliminating additional plugins
and maybe I can reconstruct/import your project or at least project facet
to figure out, where the root cause is.

Regards
 Martin
Comment 6 Mark A. Ziesemer CLA 2011-11-26 15:40:57 EST
(In reply to comment #5)
> Do you have any additional plugins installed - or just plain Eclipse JEE from
> Download?

I do need to narrow this down further.  I have the latest versions of m2e, eclipse-cs, Subclipse, and a few others installed.  I'll try to run Eclipse without various combinations of them over the past few days.

Thanks!
Comment 7 Martin W. Kirst CLA 2011-11-26 15:58:36 EST
Interesting.

My current theory: The root cause of the problem is somewhere in the plugins you've mentioned.

Because a) if the problem would be within Eclipse core, more people
would have faced it and there would be more activity regard this bug
(as it happed to bug 317785).
Because b) after interpreting the stack trace and digging a little
into the sources (and running some debug session) it seems to me, 
the the TreeViewer within the 'New File/Folder' uses standard
ViewerComperator (see ContainerSelectionGroup.java#createTreeViewer(int)).

I assume, that one of the decorators from one of the mentioned plugins
violates the Comparator contract.

I suggest not to eliminate the plugins by trying different combinations,
but find a situation (can be with all that plugins), where you can
reproduce the bug. This would be very helpful for me.
After you've found a situation, where you can reproduce the problem
(I assume it depends a little on the project layout, which resources
are used) we should find a way to share this project.
If you can't share it, we may find a way to share a similar one,
by finding the critical resources, which have to be in the project.

I think, this way we can hunt it down.

Regards
 Martin
Comment 8 Mark A. Ziesemer CLA 2011-11-26 16:15:59 EST
(In reply to comment #7)
> My current theory: The root cause of the problem is somewhere in the plugins
> you've mentioned.

You're probably right.

> I suggest not to eliminate the plugins by trying different combinations,
> but find a situation (can be with all that plugins), where you can
> reproduce the bug.

I removed the few less-common plugins I had installed and wasn't using anyway, limiting my plugins to those I listed in comment #6 + Liferay IDE.

I removed the -Djava.util.Arrays.useLegacyMergeSort=true option I had added to eclipse.ini, and am still able to regularly reproduce about 33% of the time on a simple m2e-enabled Java project.  Besides m2e, the only other plugin involved is Checkstyle.  (Project is not yet in source control with Subclipse.)  To reproduce, I'm following the same steps as in comment #0, and using simply a type of "File" - either directly underneath the project, or within a Java package.

Let me further narrow this down to only Eclipse-provided plugins, and if I can't correlate this to a specific plugin, then I'll work on providing a minimal project that can be used to reproduce.
Comment 9 Martin W. Kirst CLA 2011-11-26 16:22:23 EST
> I removed the few less-common plugins I had installed and wasn't using anyway,
> limiting my plugins to those I listed in comment #6 + Liferay IDE.
> 
> I removed the -Djava.util.Arrays.useLegacyMergeSort=true option I had added to
> eclipse.ini, and am still able to regularly reproduce about 33% of the time on
> a simple m2e-enabled Java project.  Besides m2e, the only other plugin involved
> is Checkstyle.  (Project is not yet in source control with Subclipse.)  To
> reproduce, I'm following the same steps as in comment #0, and using simply a
> type of "File" - either directly underneath the project, or within a Java
> package.
> 

Meanwhile I've installed Eclipse-CS, M2E and Subclipse. Not yet 'liferay plugin'.
I've created some test projects and put one of them under SVN the other not.
I'm now varying with some classes with and without Checkstyle violations.
Still not getting this error :-/

Will continue to varying some conditions as you've wrote, that you can reproduce it.

Regards
 Martin
Comment 10 Mark A. Ziesemer CLA 2011-11-26 16:38:19 EST
I removed the Liferay IDE plugin, without affecting the results.

I am able to almost immediately reproduce in the same workspace on a brand new Java project, without having m2e or eclipse-cs enabled on it.  Do we need to be concerned with other projects within the same workspace - even if completely unrelated to the current project?
Comment 11 Mark A. Ziesemer CLA 2011-11-26 16:42:43 EST
I also just tried creating a general project (non-Java) underneath the Navigator view.  After selecting "General/Project" from the "Select a wizard" dialog, I received an error with the same stack trace - so this doesn't appear to be project-specific.
Comment 12 Martin W. Kirst CLA 2011-11-26 16:46:13 EST
(In reply to comment #10)
> I removed the Liferay IDE plugin, without affecting the results.
OK.
 
> I am able to almost immediately reproduce in the same workspace on a brand new
> Java project, without having m2e or eclipse-cs enabled on it.  Do we need to be
> concerned with other projects within the same workspace - even if completely
> unrelated to the current project?
I think, the whole workspace counts.
Because, within the 'New file' dialog, all projects from the workspace
are shown. So, by adding a vanilla Java project, the other projects 
have influence, when they're using M2E, Checkstyle or other. -> My theory.

Still didn't got any error yet :-/

How many projects do you have within your workspace?
How many are m2e enabled?
Comment 13 Martin W. Kirst CLA 2011-11-26 16:51:43 EST
Do you have any "special things" in one of your projects?
I mean something like "link into file system" is IMHO unusual ;-)
Anything?
Comment 14 Mark A. Ziesemer CLA 2011-11-26 16:57:45 EST
(In reply to comment #13)
> Do you have any "special things" in one of your projects?
> I mean something like "link into file system" is IMHO unusual ;-)
> Anything?

Certainly no links, and nothing else special I can think of.

I did also remove eclipse-cs to rule that out.

I did create a new workspace, and am unable to immediately reproduce.  Normally, I'd never be against just moving to a new workspace if this solved the issue, but I've become somewhat attached to my current workspace, and would prefer not to start over clean.  :-)

Is there some sort of history or other cache stored within the workspace that could be suspect here, and purged - without affecting all of the workspace settings?  Otherwise, I'm copying my current workspace to one that I don't mind experimenting with - and will continue to eliminate projects and plugin metadata to further narrow this down.

Is there any additional logging options, etc., that can be enabled to show us which object class apparently isn't being compared correctly?
Comment 15 Martin W. Kirst CLA 2011-11-26 17:07:20 EST
> I did create a new workspace, and am unable to immediately reproduce. 
> Normally, I'd never be against just moving to a new workspace if this solved
> the issue, but I've become somewhat attached to my current workspace, and would
> prefer not to start over clean.  :-)
Me too ;-)

> Is there some sort of history or other cache stored within the workspace that
> could be suspect here, and purged - without affecting all of the workspace
> settings?
Not that I'm aware of.

> Otherwise, I'm copying my current workspace to one that I don't mind
> experimenting with - and will continue to eliminate projects and plugin
> metadata to further narrow this down.
OK.

> Is there any additional logging options, etc., that can be enabled to show us
> which object class apparently isn't being compared correctly?
Not that I'm aware of.

I still think, that it's somehow related to the projects layouts
and related plugins.

You may can copy your complete workspace.
If you're able t reproduce, you can safely delete some projects, to narrow down.
Comment 16 Mark A. Ziesemer CLA 2011-11-26 17:26:11 EST
OK, I learned 3 things:

1) I have too many projects in my workspace.  :-)

2) In looking for a faster way to reproduce, Ctrl+N for "New, Select a Wizard", immediately followed by the Enter key to select "Next >" on the previously-selected wizard is not only faster, but results in a higher percentage rate of reproductions.  Not sure if this is due to a timing issue?

3) Most significant - there seems to be a problem project: "Servers".  This project is used by WST, and has a .settings/org.eclipse.wst.server.core.prefs file with "org.eclipse.wst.server.core.isServerProject=true" in it.  While this project is closed, I am unable to reproduce the issue described in comment #0.  Opening and closing this project shows issues of its own.  While the open/close operations appear to succeed without issue on this project, the Eclipse Error Log shows:

Problems occurred when invoking code from plug-in: "org.eclipse.core.resources", with a NullPointerException at org.eclipse.jst.server.tomcat.core.internal.ConfigurationResourceListener.resourceChanged(ConfigurationResourceListener.java:50).  (Complete stack trace to be attached.)
Comment 17 Mark A. Ziesemer CLA 2011-11-26 17:28:40 EST
Created attachment 207574 [details]
WST Error Details
Comment 18 Martin W. Kirst CLA 2011-11-26 17:45:56 EST
> 3) Most significant - there seems to be a problem project: "Servers".  This
> project is used by WST, and has a .settings/org.eclipse.wst.server.core.prefs
> file with "org.eclipse.wst.server.core.isServerProject=true" in it.  While this
> project is closed, I am unable to reproduce the issue described in comment #0. 
> Opening and closing this project shows issues of its own.  While the open/close
> operations appear to succeed without issue on this project, the Eclipse Error
> Log shows:
> 
> Problems occurred when invoking code from plug-in:
> "org.eclipse.core.resources", with a NullPointerException at
> org.eclipse.jst.server.tomcat.core.internal.ConfigurationResourceListener.resourceChanged(ConfigurationResourceListener.java:50).
>  (Complete stack trace to be attached.)

Interesting.
Trying to add such a project ...
Comment 19 Mark A. Ziesemer CLA 2011-11-26 17:56:47 EST
Sorry - this would be easier if this was consistently reproducible.  I'm still able to reproduce now, even with the "Servers" project closed.  Will continue to try to narrow things down.

However, in the course of things, I did run into another similar but different stack trace - this one having a message of: Problems occurred when invoking code from plug-in: "org.eclipse.jface" (details to be attached).
Comment 20 Mark A. Ziesemer CLA 2011-11-26 17:57:04 EST
Created attachment 207577 [details]
jface Error Details
Comment 21 Martin W. Kirst CLA 2011-11-26 18:00:55 EST
(In reply to comment #19)
> Sorry - this would be easier if this was consistently reproducible.  I'm still
> able to reproduce now, even with the "Servers" project closed.  Will continue
> to try to narrow things down.
> 
> However, in the course of things, I did run into another similar but different
> stack trace - this one having a message of: Problems occurred when invoking
> code from plug-in: "org.eclipse.jface" (details to be attached).

OK.
But it still seems to come from some kind of 'decorator',
which decorates the projects.
Because in any case (of the two provides stack traces),
the workspace resources are displayed within a TreeView control.
Comment 22 Mark A. Ziesemer CLA 2011-11-26 18:07:30 EST
I'm beginning to think there's something else going on here.  I thought I had identified another "problem project", that once closed, I was no longer able to reproduce after making 10 attempts of "new file".  However, I then closed a few additional (but unrelated) projects, and then I was regularly reproducing with only 2-3 attempts again.  Maybe there is actually something buggy in the comparison logic somewhere?

Additionally, I've had this happen on my work computer as well.  It's a completely different workspace with completely different projects, etc. - though I do tend to configure things in a similar fashion on both computers.  (Basically, I can't just write this off as a one-computer issue.)
Comment 23 David Williams CLA 2011-11-26 19:52:32 EST
Since the stack traces mention "TimSort" towards the end, I would guess that is the source of the problem ... i.e. in the JDK, no Eclipse code. So, I searched the internet. I got so many hits, it was hard to find anything useful, but finally found this forum post, 

http://www.eclipse.org/forums/index.php/m/756308/

which let to this bug 

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7075600

That may not solve your problem ... but, I'm guessing, Eclipse can't fix it by changing Eclipse code.
Comment 24 Mark A. Ziesemer CLA 2011-11-26 20:01:36 EST
(In reply to comment #23)
> which let to this bug 
> 
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7075600
> 
> That may not solve your problem ... but, I'm guessing, Eclipse can't fix it by
> changing Eclipse code.

I'd have to agree.

I'm really curious how many users are actually running Eclipse on a 1.7 JRE/JDK - given it's still quite new, and as 1.6 is still the version provided at java.com.  We'll have to see how many other users confirm this bug report, if any.  If it becomes an apparent issue, I'd recommend at least documenting that users add -Djava.util.Arrays.useLegacyMergeSort=true to their eclipse.ini, if not making it the default somehow.
Comment 25 Martin W. Kirst CLA 2011-11-27 05:35:33 EST
(In reply to comment #23)
> Since the stack traces mention "TimSort" towards the end, I would guess that is
> the source of the problem ... i.e. in the JDK, no Eclipse code. So, I searched
> the internet. I got so many hits, it was hard to find anything useful, but
> finally found this forum post, 
> [...]
> That may not solve your problem ... but, I'm guessing, Eclipse can't fix it by
> changing Eclipse code.

Sorry, but TimSort is not the root cause, it just reveals it.
TimSort was introduced for Java 7, see
http://bugs.sun.com/view_bug.do?bug_id=6804124, because of speed and correctness.

But in opposite to its predecessor MergeSort, TimSort is much more restrictive
to the method contract of 'Comparator'. For example, in bug 317785 there
was a violation of transitivity. 

Thus, TimSort is not the root cause, but reveals some weaknesses within Eclipse code.

Regards
 Martin
Comment 26 Martin W. Kirst CLA 2011-11-27 05:37:17 EST
(In reply to comment #24)
> (In reply to comment #23)
> > which let to this bug 
> > 
> > http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7075600
> > 
> > That may not solve your problem ... but, I'm guessing, Eclipse can't fix it by
> > changing Eclipse code.
> 
> I'd have to agree.
> 
> I'm really curious how many users are actually running Eclipse on a 1.7 JRE/JDK
> - given it's still quite new, and as 1.6 is still the version provided at
> java.com.  We'll have to see how many other users confirm this bug report, if
> any.  If it becomes an apparent issue, I'd recommend at least documenting that
> users add -Djava.util.Arrays.useLegacyMergeSort=true to their eclipse.ini, if
> not making it the default somehow.

I disagree. We shouldn't use workarounds, but fix the bugs.
'useLegacyMergeSort=true' by default it's not an option, for me.
Comment 27 Martin W. Kirst CLA 2011-11-27 05:43:19 EST
(In reply to comment #22)
> I'm beginning to think there's something else going on here.  I thought I had
> identified another "problem project", that once closed, I was no longer able to
> reproduce after making 10 attempts of "new file".  However, I then closed a few
> additional (but unrelated) projects, and then I was regularly reproducing with
> only 2-3 attempts again.  Maybe there is actually something buggy in the
> comparison logic somewhere?
Nope ;-)

> Additionally, I've had this happen on my work computer as well.  It's a
> completely different workspace with completely different projects, etc. -
> though I do tend to configure things in a similar fashion on both computers. 
> (Basically, I can't just write this off as a one-computer issue.)

Consider the fact, the the workspace resources are sorted by the TreeViewer.
If you look from the birds eye view at the resources on your hard drive, 
they may looking randomly or they may looking sorted, depending on their
creation time (for example). When these resources get sorted, its a non-linear
processing (like bubble sort), but also some kind of 'random access'.
Thats these transitivity contract violations of Comparator are so hard to
predict.
Comment 28 Martin W. Kirst CLA 2011-11-27 05:44:30 EST
It would be really useful, if someone could provide it's "broken" workspace,
that others can reproduce the problem.

I'm still trying to find a situation, where it crashes - at least once :-/
Comment 29 Martin W. Kirst CLA 2011-11-27 06:38:51 EST
OK, found something.

The ViewerComperator.java#compare() method has an Integer overflow,
when comparing the categories:
-----
if (cat1 != cat2) {
   return cat1 - cat2;
}
-----

But I can't imagine how this will lead to a crash, 
because I didn't found any 'big numbers' :-/
Comment 30 Martin W. Kirst CLA 2011-11-28 16:11:08 EST
Created attachment 207626 [details]
Blind guess patch, fixing integer overflow in ViewerComperator, including pre-compiled JAR

I've added a "blind guess patch".
Because of I couldn't reproduce the bug, but found the integer overflow
within ViewerComperator, I've fixed it.
Hence, it's a blind guess ;-)

The attachment org.eclipse.jface-blind_guess1.zip contains the patch.
Additionally I've exported the .JAR.

To apply the patch:
 1. create a backup of you Eclipse installation
 2. replace $ECLIPSE_HOME\plugins\org.eclipse.jface_3.7.0.I20110522-1430.jar
    with the attached version.

@Mark, would you please check it out?
Comment 31 Mark A. Ziesemer CLA 2011-11-28 16:14:03 EST
(In reply to comment #30)
> @Mark, would you please check it out?

Certainly!  Unfortunately, I've not run into this issue for a while now.  I'll wait until I start running into it again, as well as seeing if my environment at work is still having the same issue.  Once I'm running into it again, then I'll apply your patch and see if it helps resolve the issue.

THANKS!!
Comment 32 Paul Webster CLA 2011-11-29 07:52:25 EST
(In reply to comment #30)
> Created attachment 207626 [details]
> Blind guess patch, fixing integer overflow in ViewerComperator, including
> pre-compiled JAR
> 
> I've added a "blind guess patch".
> Because of I couldn't reproduce the bug, but found the integer overflow
> within ViewerComperator, I've fixed it.
> Hence, it's a blind guess ;-)

Depending on what subclass of ViewerComparator is used, it defaults to using the Strings returned by the LabelProvider for that viewer.  But if it supports decorators then the String returned might change between runs of the sort algorithm, and that might cause the bug, no?

PW
Comment 34 Peter Larsen CLA 2011-12-05 08:41:55 EST
A coworker had some problems, and wanted to upgrade to newest version to see if his problem was fixed. Instead he got this:


!SESSION 2011-12-01 13:56:02.495 -----------------------------------------------
eclipse.buildId=I20110613-1736
java.version=1.7.0
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product



!ENTRY org.eclipse.core.jobs 4 2 2011-12-05 13:06:42.366
!MESSAGE An internal error occurred during: "Install download3".
!STACK 0
java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.ComparableTimSort.mergeHi(Unknown Source)
	at java.util.ComparableTimSort.mergeAt(Unknown Source)
	at java.util.ComparableTimSort.mergeForceCollapse(Unknown Source)
	at java.util.ComparableTimSort.sort(Unknown Source)
	at java.util.ComparableTimSort.sort(Unknown Source)
	at java.util.Arrays.sort(Unknown Source)
	at org.eclipse.equinox.internal.p2.artifact.repository.MirrorSelector.hasValidMirror(MirrorSelector.java:319)
	at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.downloadArtifact(SimpleArtifactRepository.java:577)
	at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.getArtifact(SimpleArtifactRepository.java:680)
	at org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest.getArtifact(MirrorRequest.java:260)
	at org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest.transferSingle(MirrorRequest.java:235)
	at org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest.transfer(MirrorRequest.java:191)
	at org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest.perform(MirrorRequest.java:122)
	at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.getArtifact(SimpleArtifactRepository.java:664)
	at org.eclipse.equinox.internal.p2.artifact.repository.simple.DownloadJob.run(DownloadJob.java:63)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 35 Remy Suen CLA 2011-12-05 08:47:17 EST
(In reply to comment #34)
> A coworker had some problems, and wanted to upgrade to newest version to see if
> his problem was fixed.

You want bug 317785.
Comment 36 Paul Webster CLA 2011-12-05 08:49:56 EST
(In reply to comment #34)
> 
> !SESSION 2011-12-01 13:56:02.495
> -----------------------------------------------
> eclipse.buildId=I20110613-1736
> java.version=1.7.0
> java.vendor=Oracle Corporation
> BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
> Framework arguments:  -product org.eclipse.epp.package.java.product
> Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product
> org.eclipse.epp.package.java.product
> 
> 

that's a different problem: bug 317785  There should be a workaround on the other bug to update from that build to the one with the fix for the update bug.

But no release contains a fix for this bug, as it hasn't been fixed.  3.8 M4 and 4.2 M4 will contain logging that should help us track this down.

PW
Comment 37 Peter Larsen CLA 2011-12-05 08:58:06 EST
(In reply to comment #35)
> You want bug 317785.

I are right.
Comment 38 Peter Larsen CLA 2011-12-05 08:58:41 EST
Sorry for spam, I meant to write
You are right.
Comment 39 Dani Megert CLA 2011-12-06 08:11:05 EST
(In reply to comment #33)
> Created attachment 207651 [details] [diff]
> Logging of state at the time of the exception
> 
> 4.2:
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=292131cab2810efc8743447f56509bdee53b22c8
> 
> 3.8:
> 
> http://git.eclipse.org/c/platform/eclipse.platform.ui.git/commit/?id=b6f90205a98fd94518675fa7517dc47f397005f0
> 
> PW

This change can cause NPEs, see bug 365720.
Comment 40 Mark A. Ziesemer CLA 2011-12-08 16:40:27 EST
Created attachment 208126 [details]
Subclipse Error Details

Just started getting this error again at work.  I have Subclipse installed, and tried right-clicking on a folder (doesn't matter which one or in which project - able to do so 10+ times in a row now), "Team", "Copy...".  The stack trace captured in the Eclipse error log is largely identical.

I'll restart Eclipse as-is, see if I can still reproduce, and then if so, restart again with Martin's patch to see if it helps resolve the issue.
Comment 41 Mark A. Ziesemer CLA 2011-12-08 16:51:13 EST
Restarted, and was able to reproduce - though frustratingly, not with the same consistency as reported in comment #40.  Restarted again with the patch from attachment #207626 [details], and after a few additional tries to reproduce, I again received the exact same error.  So sorry Martin, your first attempt at a blind patch didn't seem to resolve this.

Paul / anyone - is there a similar patched JAR I can get to help with trying to reproduce this with proper logging in effect (re: comment # 33)?
Comment 42 Martin W. Kirst CLA 2011-12-08 17:07:14 EST
(In reply to comment #41)
> [..]  So sorry Martin, your first attempt at a blind
> patch didn't seem to resolve this.
Thanks, but was worth a try.

Anyone else can reproduce the bug?
And maybe provide/share his/her workspace?
Comment 43 Paul Webster CLA 2011-12-08 19:04:27 EST
(In reply to comment #41)
> Paul / anyone - is there a similar patched JAR I can get to help with trying to
> reproduce this with proper logging in effect (re: comment # 33)?

Can you try one of the 3.8 - http://download.eclipse.org/eclipse/downloads/eclipse3x.php  or 4.2 http://download.eclipse.org/eclipse/downloads/ current I builds?  They both have the logging in them.

If you are comfortable applying and deploying a patched jar to run with the logging, try http://git.eclipse.org/c/platform/eclipse.platform.ui.git/patch/?id=b6f90205a98fd94518675fa7517dc47f397005f0

You can apply it to the workspace root, and then remove the first 2 segments.

PW
Comment 44 Andrey Loskutov CLA 2011-12-12 16:54:40 EST
(In reply to comment #43)
> Can you try one of the 3.8 -
> http://download.eclipse.org/eclipse/downloads/eclipse3x.php  or 4.2
> http://download.eclipse.org/eclipse/downloads/ current I builds?  They both
> have the logging in them.

Hi, I was seeing the problem today immediately at startup of my workspace (running 3.8 M4).

Below the stack:

java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeLo(TimSort.java:747)
	at java.util.TimSort.mergeAt(TimSort.java:483)
	at java.util.TimSort.mergeCollapse(TimSort.java:410)
	at java.util.TimSort.sort(TimSort.java:214)
	at java.util.TimSort.sort(TimSort.java:173)
	at java.util.Arrays.sort(Arrays.java:659)
	at org.eclipse.jface.viewers.ViewerComparator.sort(ViewerComparator.java:187)
	at org.eclipse.ui.internal.progress.DetailedProgressViewer.add(DetailedProgressViewer.java:166)
	at org.eclipse.ui.internal.progress.ProgressViewerContentProvider.add(ProgressViewerContentProvider.java:224)
	at org.eclipse.ui.internal.progress.ProgressViewUpdater$1.runInUIThread(ProgressViewUpdater.java:285)
	at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3563)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3212)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	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:352)
	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:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:624)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:579)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1433)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1409)

message: Comparison method violates its general contract!
this: org.eclipse.ui.internal.progress.ProgressManagerUtil$1
comparator: null
array:
	org.eclipse.ui.internal.progress.JobInfo@19ab9ab5
	org.eclipse.ui.internal.progress.JobInfo@4d56d431
	org.eclipse.ui.internal.progress.JobInfo@127eb604
	org.eclipse.ui.internal.progress.JobInfo@18bafeaf
	org.eclipse.ui.internal.progress.JobInfo@3ee3e9c1
	org.eclipse.ui.internal.progress.JobInfo@4bfa8bdd
	org.eclipse.ui.internal.progress.JobInfo@f4a3867
	org.eclipse.ui.internal.progress.JobInfo@ac69af8
	org.eclipse.ui.internal.progress.JobInfo@30ceefd8
	org.eclipse.ui.internal.progress.JobInfo@46d982c4
	org.eclipse.ui.internal.progress.JobInfo@43c9ffbe
	org.eclipse.ui.internal.progress.JobInfo@64b6ea43
	org.eclipse.ui.internal.progress.JobInfo@11a5592
	org.eclipse.ui.internal.progress.JobInfo@4dee823a
	org.eclipse.ui.internal.progress.JobInfo@49d6d508
	org.eclipse.ui.internal.progress.JobInfo@447d0c6c
	org.eclipse.ui.internal.progress.JobInfo@74c382d
	org.eclipse.ui.internal.progress.JobInfo@f9a3121
	org.eclipse.ui.internal.progress.JobInfo@631e2173
	org.eclipse.ui.internal.progress.JobInfo@402c8ee0
	org.eclipse.ui.internal.progress.JobInfo@2d8d9e1b
	org.eclipse.ui.internal.progress.JobInfo@e519ebe
	org.eclipse.ui.internal.progress.JobInfo@9a2cb89
	org.eclipse.ui.internal.progress.JobInfo@63cc0e4a
	org.eclipse.ui.internal.progress.JobInfo@5e78db10
	org.eclipse.ui.internal.progress.JobInfo@34a970bb
	org.eclipse.ui.internal.progress.JobInfo@3a6bc460
	org.eclipse.ui.internal.progress.JobInfo@33407620
	org.eclipse.ui.internal.progress.JobInfo@5669b845
	org.eclipse.ui.internal.progress.JobInfo@23351839
	org.eclipse.ui.internal.progress.JobInfo@542dba3f
	org.eclipse.ui.internal.progress.JobInfo@1f43243e
	org.eclipse.ui.internal.progress.JobInfo@1c421a95
	org.eclipse.ui.internal.progress.JobInfo@3cffca52
	org.eclipse.ui.internal.progress.JobInfo@79d36bd3
	org.eclipse.ui.internal.progress.JobInfo@5a09457d
	org.eclipse.ui.internal.progress.JobInfo@327a2403
	org.eclipse.ui.internal.progress.JobInfo@561d3375
	org.eclipse.ui.internal.progress.JobInfo@61789881
	org.eclipse.ui.internal.progress.JobInfo@10904219
	org.eclipse.ui.internal.progress.JobInfo@739e71ab
	org.eclipse.ui.internal.progress.JobInfo@209896c
	org.eclipse.ui.internal.progress.JobInfo@7702708d
	org.eclipse.ui.internal.progress.JobInfo@7a023ac7
	org.eclipse.ui.internal.progress.JobInfo@72c76b65
	org.eclipse.ui.internal.progress.JobInfo@42ed1d2e
	org.eclipse.ui.internal.progress.JobInfo@4de8cc55
	org.eclipse.ui.internal.progress.JobInfo@3a55334a
	org.eclipse.ui.internal.progress.JobInfo@6a0ed22c
	org.eclipse.ui.internal.progress.JobInfo@5ff382e4
	org.eclipse.ui.internal.progress.JobInfo@c94ad54
	org.eclipse.ui.internal.progress.JobInfo@5173cfa9
	org.eclipse.ui.internal.progress.JobInfo@27ccb204
	org.eclipse.ui.internal.progress.JobInfo@1ffeca59
	org.eclipse.ui.internal.progress.JobInfo@aa26d1c
	org.eclipse.ui.internal.progress.JobInfo@2b56c208
	org.eclipse.ui.internal.progress.JobInfo@5025a5db
	org.eclipse.ui.internal.progress.JobInfo@1a5e8658
	org.eclipse.ui.internal.progress.JobInfo@5164bc93
	org.eclipse.ui.internal.progress.JobInfo@a6bf5fd
Comment 45 Martin W. Kirst CLA 2011-12-12 17:53:21 EST
Hi,

your stack trace looks different - interesting detail.
Can you provide your workspace - or at least more details about?

Regards
 Martin

> Hi, I was seeing the problem today immediately at startup of my workspace
> (running 3.8 M4).
> 
> Below the stack:
> 
> java.lang.IllegalArgumentException: Comparison method violates its general
> contract!
>     at java.util.TimSort.mergeLo(TimSort.java:747)
>     at java.util.TimSort.mergeAt(TimSort.java:483)
>     at java.util.TimSort.mergeCollapse(TimSort.java:410)
>     at java.util.TimSort.sort(TimSort.java:214)
>     at java.util.TimSort.sort(TimSort.java:173)
>     at java.util.Arrays.sort(Arrays.java:659)
>     at [...]
Comment 46 Andrey Loskutov CLA 2011-12-12 17:58:52 EST
(In reply to comment #45)
> your stack trace looks different - interesting detail.
> Can you provide your workspace - or at least more details about?

Do you want my .metadata? This is what AnyEdit reports me:

"Workspace contains 14825 resources:
13694 files in 1107 folders and 24 projects.

In average each folder contains 12 files, and each project 616 resources.

There are also 587 hidden team files and 139 hidden team folders.

*Without* team resources selection would contain 14099 resources:
13107 files in 968 folders and 24 projects.

In average each folder would contain 13 files, and each project 586 resources."

:-)
Comment 47 Remy Suen CLA 2011-12-12 18:27:14 EST
(In reply to comment #44)
> java.lang.IllegalArgumentException: Comparison method violates its general
> contract!
>     at java.util.TimSort.mergeLo(TimSort.java:747)
>     at java.util.TimSort.mergeAt(TimSort.java:483)
>     at java.util.TimSort.mergeCollapse(TimSort.java:410)
>     at java.util.TimSort.sort(TimSort.java:214)
>     at java.util.TimSort.sort(TimSort.java:173)
>     at java.util.Arrays.sort(Arrays.java:659)
>     at
> org.eclipse.jface.viewers.ViewerComparator.sort(ViewerComparator.java:187)
>     at
> org.eclipse.ui.internal.progress.DetailedProgressViewer.add(DetailedProgressViewer.java:166)

This is bug 361121.
Comment 48 Martin W. Kirst CLA 2011-12-13 18:30:34 EST
(In reply to comment #46)
> (In reply to comment #45)
> > your stack trace looks different - interesting detail.
> > Can you provide your workspace - or at least more details about?
> 
> Do you want my .metadata? This is what AnyEdit reports me:
> 
> "Workspace contains 14825 resources:
> 13694 files in 1107 folders and 24 projects.
> [...]

Thanks for these details, but I meant other ones ;-)

To be a little bit more precise:
* What kind of Eclipse do you use? (JEE, Classic etc)
* What additional plugins do you have installed?
* What OS?
* Project layout? (SVN, Maven etc?)

As you can read in history, there are a few plugins mentioned from Mark.

I have the sources on my desk, but can't reproduce this bug in any way :-/
Any help, so that I/other can reproduce this bug is welcome.
Comment 49 Mark A. Ziesemer CLA 2013-07-29 11:23:08 EDT
This is still happening under 4.3 / I20130605-2000 .  (Should the "Version" on this ticket be updated to 4.3 to reflect, or left at 4.2 - since ranges apparently aren't supported here?)

Restarting Eclipse seems to fix the problem for a while, but the problem always re-appears after some time.

I'll upload some new stack traces - but org.eclipse.jface.viewers.ViewerComparator.sort(ViewerComparator.java:187) is still a common frame - and one that also seems to make bug # 403533 a duplicate of this issue.

Additionally, right alongside the "Unhandled event loop exception" being seen in the Eclipse "Error Log", it is also showing a "Workaround for comparator violation:" error (from "org.eclipse.jface").  I'll include (most of) this as well - but it includes:

message: Comparison method violates its general contract!
this: org.eclipse.jface.viewers.ViewerComparator
comparator: com.ibm.icu.text.RuleBasedCollator
array: ...

I'd rather not need to keep -Djava.util.Arrays.useLegacyMergeSort=true around as a work-around for this.

I can include the contents of "array" directly to an individual working on this who might need this for troubleshooting, but can't post it publicly here.
Comment 50 Dani Megert CLA 2013-07-29 11:26:36 EDT
(In reply to comment #49)
> This is still happening under 4.3 / I20130605-2000 .  (Should the "Version"
> on this ticket be updated to 4.3 to reflect, or left at 4.2 - since ranges
> apparently aren't supported here?)

Please leave it as is.
Comment 51 Mark A. Ziesemer CLA 2013-07-29 11:28:22 EDT
Created attachment 233895 [details]
Stack Trace from Error Log.
Comment 52 Mark A. Ziesemer CLA 2013-07-29 11:28:57 EDT
Created attachment 233896 [details]
"Workaround for comparator violation" from Error Log.
Comment 53 Paul Webster CLA 2013-07-29 13:52:22 EDT
(In reply to comment #51)
> Created attachment 233895 [details]
> Stack Trace from Error Log.

Hi Mark,

Thanks for the stack trace.  What were you doing when this occurred?  Do something and then open the new file wizard?  Did you just use CTRL+N to open it?  Did you have to advance forward and select the specific type of wizard?

PW
Comment 54 Mark A. Ziesemer CLA 2013-07-29 14:42:38 EDT
(In reply to comment #53)

> What were you doing when this occurred?  Do something and then open the new file wizard?  Did you just use CTRL+N to open it?  Did you have to advance forward and select the specific type of wizard?

I was working on a Java project (m2e-enabled), and needed to create a "flat file" within the project directory for the process to read from.  I did not try Ctrl+N, but did what should have been equivalent:  Right-click, expand "New", and click on "Other...".  At this point, nothing happens.  The "Select a wizard" page / dialog never even appears.  (I was hoping to get to "General" / "File".)
Comment 55 Dani Megert CLA 2013-08-16 06:26:28 EDT
(In reply to comment #51)
> Created attachment 233895 [details]
> Stack Trace from Error Log.

This looks strange. Did you manually edit this? 4.3 would log this problem differently.
Comment 56 Mark A. Ziesemer CLA 2013-08-17 11:41:58 EDT
(In reply to comment #55)

> This looks strange. Did you manually edit this? 4.3 would log this problem
> differently.

No - this is a direct copy "export" from the error log.
Comment 57 Dani Megert CLA 2013-08-19 03:42:53 EDT
(In reply to comment #56)
> (In reply to comment #55)
> 
> > This looks strange. Did you manually edit this? 4.3 would log this problem
> > differently.
> 
> No - this is a direct copy "export" from the error log.

The .log should also contain information similar to https://bugs.eclipse.org/bugs/attachment.cgi?id=233896
Comment 58 Andrey Loskutov CLA 2013-12-07 05:11:31 EST
Created attachment 238137 [details]
error log on "create new file"

I've got this error now reproducibly in 4.3.1 by trying to create new file from package explorer view.

Steps to reproduce:

Open package explorer
Make sure there are few working sets with few projects each.
Select one project, right click it and choose "New->File"
2 errors will be reported in the error log, no file is created/opened.

Log is attached, same stack as from Mark.
Comment 59 Andrey Loskutov CLA 2013-12-07 05:16:00 EST
P.S.
"File->New" menu from global window menu works on same project! 

The error is reproducible only if one uses the context menu from the package or project explorer or navigator views. Working sets are not relevant.
Comment 60 Andrey Loskutov CLA 2013-12-07 09:17:44 EST
P.S.S.
Seems that this isn't such simple. Now it crashes with the same stack trace also with the global window "File->New->File" menu...

I've managed to see the fail often it one single workspace, not reliable. Unfortunately I was not able to debug the problem, but I think the conclusions below could help.

The preconditions are:
1) Workspace containing > 32 opened projects (see TimSort.MIN_MERGE)
2) At least one resource text decorator contributed as "adaptable" (see DecoratorManager.decorateText:512)
3) Most likely two of the decorators contributing non-empty text decorations for the same project (?why?)

This is timing dependent issue, I think caused by the race conditions in DecorationScheduler. In my case I have GitLightweightDecorator (from EGit) and ResourceBugCountDecorator (from FindBugs) contributing the branch name and number if FB warnings to the project label. Disabling any one of the two fixes the problem immediately, disables both makes it appear pretty often (but still not in reproducible way!).

I imagine that the problem could be: timsort does few rounds, ViewerComparator computes text+decorations each time called (and can produce different labels for the same object!), so that timsort sees different results depending on the round => kaboom. 

I don't get the point why I need at least two decorators to reproduce the issue, but I hope someone here have some idea. 

Also I'm not seeing this problem on 3.8.1, so the problem could be "reduced" to the changes between 3.8 and 4.2 where it was observed for the first time. 

Below are few related code snippets.

org.eclipse.ui.internal.ide.misc.ContainerSelectionGroup:

treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
treeViewer.setComparator(new ViewerComparator());
...
treeViewer.setInput(ResourcesPlugin.getWorkspace()); // <- Kaboom!


org.eclipse.ui.model.WorkbenchLabelProvider:

public static ILabelProvider getDecoratingWorkbenchLabelProvider() {
     return new DecoratingLabelProvider(new WorkbenchLabelProvider(),
           PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator());
}

org.eclipse.ui.internal.decorators.DecoratorManager:

public ILabelDecorator getLabelDecorator() {
	return new ManagedWorkbenchLabelDecorator(this);
}

org.eclipse.ui.internal.decorators.DecoratorManager:
public String decorateText(String text, Object element, IDecorationContext context) {
	Object adapted = getResourceAdapter(element);
	String result = scheduler.decorateWithText(text, element, adapted, context);
...

org.eclipse.ui.internal.decorators.DecorationScheduler:
	
public String decorateWithText(String text, Object element,
	Object adaptedElement, IDecorationContext context) {
	DecorationResult decoration = getResult(element, adaptedElement, context);
	if (decoration == null) {
		return text; // !!! Race conditions: first time same text !!!
	}
	return decoration.decorateWithText(text); // !!! later: decorated text !!!
}

private DecorationResult getResult(Object element, Object adaptedElement,
			IDecorationContext context) {
	if (element == null) {
		return null;
	}
	DecorationResult decoration = internalGetResult(element, context);
	if (decoration == null) {
		queueForDecoration(element, adaptedElement, false, null, context);
		return null; // !!! first time no decoration !!!
	}
	return decoration;
}
Comment 61 Jari Juslin CLA 2014-01-31 05:45:02 EST
I get similar stack traces several per hour with Luna M4, Ubuntu 13.10 + Cinnamon, Oracle JVM v1.7u51:

org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.IllegalArgumentException: Comparison method violates its general contract!)
        at org.eclipse.swt.SWT.error(SWT.java:4419)
        at org.eclipse.swt.SWT.error(SWT.java:4334)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:139)
        at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3746)
        at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3394)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1122)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1006)
        at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:146)
        at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
        at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
        at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:565)
        at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:125)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:109)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:80)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:372)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:226)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
        at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
        at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
        at java.util.TimSort.mergeHi(TimSort.java:868)
        at java.util.TimSort.mergeAt(TimSort.java:485)
        at java.util.TimSort.mergeCollapse(TimSort.java:410)
        at java.util.TimSort.sort(TimSort.java:214)
        at java.util.TimSort.sort(TimSort.java:173)
        at java.util.Arrays.sort(Arrays.java:659)
        at org.eclipse.jface.viewers.TreePathViewerSorter.sort(TreePathViewerSorter.java:103)
        at org.eclipse.jface.viewers.AbstractTreeViewer.getSortedChildren(AbstractTreeViewer.java:640)
        at org.eclipse.jface.viewers.AbstractTreeViewer.updateChildren(AbstractTreeViewer.java:2665)
        at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefreshStruct(AbstractTreeViewer.java:1937)
        at org.eclipse.jface.viewers.TreeViewer.internalRefreshStruct(TreeViewer.java:749)
        at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefresh(AbstractTreeViewer.java:1912)
        at org.eclipse.jface.viewers.AbstractTreeViewer.internalRefresh(AbstractTreeViewer.java:1869)
        at org.eclipse.ui.navigator.CommonViewer.internalRefresh(CommonViewer.java:561)
        at org.eclipse.jface.viewers.StructuredViewer$8.run(StructuredViewer.java:1545)
        at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1452)
        at org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:426)
        at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1413)
        at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1543)
        at org.eclipse.jface.viewers.ColumnViewer.refresh(ColumnViewer.java:568)
        at org.eclipse.ui.navigator.CommonViewer.refresh(CommonViewer.java:350)
        at org.eclipse.ui.navigator.CommonViewer.refresh(CommonViewer.java:510)
        at org.eclipse.jst.jee.ui.internal.navigator.JEE5ContentProvider$1.run(JEE5ContentProvider.java:145)
        at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
        at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:136)
        ... 24 more
Comment 62 Heiko Böttger CLA 2014-04-01 09:40:55 EDT
Just an idea. Is it possible to add some try-catch-blocks in the CommonNavigator, ViewerComparator and other areas to extend the error message by the name of the comparator?

May be someone has a good contact at oracle. If the error message would print out the fullyqualified classname of the violating comparator these problems could be easier resolved.
Comment 63 David I CLA 2014-08-19 17:12:14 EDT
I'm seeing this problem in Luna when trying to create a new General Project:

[Message] Unhandled event loop exception
java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeHi(TimSort.java:868)
	at java.util.TimSort.mergeAt(TimSort.java:485)
	at java.util.TimSort.mergeForceCollapse(TimSort.java:426)
	at java.util.TimSort.sort(TimSort.java:223)
	at java.util.TimSort.sort(TimSort.java:173)
	at java.util.Arrays.sort(Arrays.java:659)
	at org.eclipse.jface.viewers.ViewerComparator.sort(ViewerComparator.java:189)
	at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren(StructuredViewer.java:1061)
	at org.eclipse.jface.viewers.AbstractTableViewer.internalRefreshAll(AbstractTableViewer.java:667)
	at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:615)
	at org.eclipse.jface.viewers.AbstractTableViewer.internalRefresh(AbstractTableViewer.java:607)
	at org.eclipse.jface.viewers.AbstractTableViewer$1.run(AbstractTableViewer.java:567)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1436)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1397)
	at org.eclipse.jface.viewers.CheckboxTableViewer.preservingSelection(CheckboxTableViewer.java:344)
	at org.eclipse.jface.viewers.AbstractTableViewer.inputChanged(AbstractTableViewer.java:564)
	at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:292)
	at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1675)
	at org.eclipse.ui.dialogs.WizardNewProjectReferencePage.createControl(WizardNewProjectReferencePage.java:98)
	at org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1276)
	at org.eclipse.jface.wizard.WizardDialog.access$4(WizardDialog.java:1268)
	at org.eclipse.jface.wizard.WizardDialog$8.run(WizardDialog.java:1257)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1254)
	at org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:942)
	at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:434)
	at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:619)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4486)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3831)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3441)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:832)
	at org.eclipse.jface.window.Window.open(Window.java:808)
	at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:269)
	at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:290)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:247)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:229)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:149)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:499)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:343)
	at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:159)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4486)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1388)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3831)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3441)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1151)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1032)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:148)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:636)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:579)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:135)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:382)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:236)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:648)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:603)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)
[Emitter] org.eclipse.ui
Comment 64 Vlasceanu Victor CLA 2015-09-21 05:42:45 EDT
Hello,

I have the same problem using org.eclipse.jface_3.7.0.I20110522-1430.jar:

java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeLo(TimSort.java:747)
	at java.util.TimSort.mergeAt(TimSort.java:483)
	at java.util.TimSort.mergeCollapse(TimSort.java:410)
	at java.util.TimSort.sort(TimSort.java:214)
	at java.util.TimSort.sort(TimSort.java:173)
	at java.util.Arrays.sort(Arrays.java:659)
	at org.eclipse.jface.viewers.ViewerComparator.sort(ViewerComparator.java:185)
	at org.eclipse.jface.viewers.StructuredViewer.getSortedChildren(StructuredViewer.java:1071)
	at org.eclipse.ui.internal.progress.DetailedProgressViewer.refreshAll(DetailedProgressViewer.java:486)
	at org.eclipse.ui.internal.progress.DetailedProgressViewer.internalRefresh(DetailedProgressViewer.java:383)
	at org.eclipse.jface.viewers.StructuredViewer.internalRefresh(StructuredViewer.java:1299)
	at org.eclipse.jface.viewers.StructuredViewer$8.run(StructuredViewer.java:1535)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1443)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1404)
	at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1533)
	at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1490)
	at org.eclipse.ui.internal.progress.ProgressViewerContentProvider.refresh(ProgressViewerContentProvider.java:140)
	at org.eclipse.ui.internal.progress.ProgressViewerContentProvider$3.runInUIThread(ProgressViewerContentProvider.java:117)
	at org.eclipse.ui.progress.UIJob$1.run(UIJob.java:95)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)

There is any known workaround ?
Comment 65 Paul Webster CLA 2015-09-21 09:48:57 EDT
(In reply to Vlasceanu Victor from comment #64)
> Hello,
> 
> I have the same problem using org.eclipse.jface_3.7.0.I20110522-1430.jar:
> 
> java.lang.IllegalArgumentException: Comparison method violates its general
> contract!

A workaround is mentioned in comment #24

PW
Comment 66 Vlasceanu Victor CLA 2015-09-21 09:52:42 EDT
(In reply to Paul Webster from comment #65)
> (In reply to Vlasceanu Victor from comment #64)
> > Hello,
> > 
> > I have the same problem using org.eclipse.jface_3.7.0.I20110522-1430.jar:
> > 
> > java.lang.IllegalArgumentException: Comparison method violates its general
> > contract!
> 
> A workaround is mentioned in comment #24
> 
> PW

Thank you,
Can you tell me what is the impact of this change?

Victor.
Comment 67 Paul Webster CLA 2015-09-21 11:22:11 EDT
(In reply to Vlasceanu Victor from comment #66)
> Thank you,
> Can you tell me what is the impact of this change?

It's just asking the JDK to use the default sort as it did prior to Java 7 (which didn't highlight our comparitor problem).  I don't know the particulars, but there must be some discussions of it on the web.

PW
Comment 68 sayresVT CLA 2016-02-05 12:32:41 EST
Seems to still be happening in Mars.  For me, it happens every time I right click on the src/main folder in a Maven project and select New->Folder.

eclipse.buildId=4.5.1.M20150904-0015
java.version=1.7.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

org.eclipse.ui
Error
Fri Feb 05 12:27:41 EST 2016
Unhandled event loop exception

java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeHi(TimSort.java:868)
	at java.util.TimSort.mergeAt(TimSort.java:485)
	at java.util.TimSort.mergeForceCollapse(TimSort.java:426)
	at java.util.TimSort.sort(TimSort.java:223)
	at java.util.TimSort.sort(TimSort.java:173)
	at java.util.Arrays.sort(Arrays.java:659)
	at org.eclipse.jface.viewers.ViewerComparator.sort(ViewerComparator.java:189)
	at org.eclipse.jface.viewers.AbstractTreeViewer.getSortedChildren(AbstractTreeViewer.java:640)
	at org.eclipse.jface.viewers.AbstractTreeViewer$1.run(AbstractTreeViewer.java:815)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:791)
	at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:611)
	at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:762)
	at org.eclipse.jface.viewers.AbstractTreeViewer.internalInitializeTree(AbstractTreeViewer.java:1541)
	at org.eclipse.jface.viewers.TreeViewer.internalInitializeTree(TreeViewer.java:790)
	at org.eclipse.jface.viewers.AbstractTreeViewer$5.run(AbstractTreeViewer.java:1525)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1462)
	at org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:366)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1423)
	at org.eclipse.jface.viewers.AbstractTreeViewer.inputChanged(AbstractTreeViewer.java:1517)
	at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:292)
	at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1701)
	at org.eclipse.ui.internal.ide.misc.ContainerSelectionGroup.createTreeViewer(ContainerSelectionGroup.java:301)
	at org.eclipse.ui.internal.ide.misc.ContainerSelectionGroup.createContents(ContainerSelectionGroup.java:244)
	at org.eclipse.ui.internal.ide.misc.ContainerSelectionGroup.<init>(ContainerSelectionGroup.java:168)
	at org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup.createContents(ResourceAndContainerGroup.java:228)
	at org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup.<init>(ResourceAndContainerGroup.java:186)
	at org.eclipse.ui.dialogs.WizardNewFolderMainPage.createControl(WizardNewFolderMainPage.java:279)
	at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:175)
	at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:705)
	at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:597)
	at org.eclipse.jface.window.Window.create(Window.java:430)
	at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1096)
	at org.eclipse.ui.internal.actions.NewWizardShortcutAction.run(NewWizardShortcutAction.java:123)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:473)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:595)
	at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:511)
	at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:827)
	at org.eclipse.jface.window.Window.open(Window.java:803)
	at org.eclipse.ui.internal.views.log.EventDetailsDialog.open(EventDetailsDialog.java:181)
	at org.eclipse.ui.internal.views.log.EventDetailsDialogAction.run(EventDetailsDialogAction.java:98)
	at org.eclipse.ui.internal.views.log.LogView$15.doubleClick(LogView.java:546)
	at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:832)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:173)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:829)
	at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1470)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1263)
	at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:252)
	at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:249)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:311)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
Comment 69 Dani Megert CLA 2016-02-08 04:49:35 EST
(In reply to sayresVT from comment #68)
> Seems to still be happening in Mars.  For me, it happens every time I right
> click on the src/main folder in a Maven project and select New->Folder.

The exception comes from org.eclipse.ui.internal.ide.misc. which is not "us". It's probably a bug in their comparator.
Comment 70 Jacob Weber CLA 2016-09-02 13:12:10 EDT
I'm seeing the same behavior with Eclipse 4.6.0 on a Mac, build id: 20160613-1800. Hit command-N for the New dialog, click on File or Folder, and half of the time I get the following exception:

java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeHi(TimSort.java:895)
	at java.util.TimSort.mergeAt(TimSort.java:512)
	at java.util.TimSort.mergeForceCollapse(TimSort.java:453)
	at java.util.TimSort.sort(TimSort.java:250)
	at java.util.Arrays.sort(Arrays.java:1438)
	at org.eclipse.jface.viewers.ViewerComparator.sort(ViewerComparator.java:193)
	at org.eclipse.jface.viewers.AbstractTreeViewer.getSortedChildren(AbstractTreeViewer.java:644)
	at org.eclipse.jface.viewers.AbstractTreeViewer.lambda$0(AbstractTreeViewer.java:817)
	at org.eclipse.jface.viewers.AbstractTreeViewer$$Lambda$51/481660042.run(Unknown Source)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:795)
	at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:596)
	at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:766)
	at org.eclipse.jface.viewers.AbstractTreeViewer.internalInitializeTree(AbstractTreeViewer.java:1538)
	at org.eclipse.jface.viewers.TreeViewer.internalInitializeTree(TreeViewer.java:772)
	at org.eclipse.jface.viewers.AbstractTreeViewer.lambda$1(AbstractTreeViewer.java:1523)
	at org.eclipse.jface.viewers.AbstractTreeViewer$$Lambda$50/1230539888.run(Unknown Source)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1458)
	at org.eclipse.jface.viewers.TreeViewer.preservingSelection(TreeViewer.java:354)
	at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1419)
	at org.eclipse.jface.viewers.AbstractTreeViewer.inputChanged(AbstractTreeViewer.java:1517)
	at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:286)
	at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1696)
	at org.eclipse.ui.internal.ide.misc.ContainerSelectionGroup.createTreeViewer(ContainerSelectionGroup.java:291)
	at org.eclipse.ui.internal.ide.misc.ContainerSelectionGroup.createContents(ContainerSelectionGroup.java:240)
	at org.eclipse.ui.internal.ide.misc.ContainerSelectionGroup.<init>(ContainerSelectionGroup.java:164)
	at org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup.createContents(ResourceAndContainerGroup.java:228)
	at org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup.<init>(ResourceAndContainerGroup.java:186)
	at org.eclipse.ui.dialogs.WizardNewFileCreationPage.createControl(WizardNewFileCreationPage.java:247)
	at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:175)
	at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:696)
	at org.eclipse.jface.wizard.WizardDialog.setWizard(WizardDialog.java:1144)
	at org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1197)
	at org.eclipse.jface.wizard.WizardDialog.lambda$2(WizardDialog.java:1185)
	at org.eclipse.jface.wizard.WizardDialog$$Lambda$80/613611259.run(Unknown Source)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1185)
	at org.eclipse.ui.internal.dialogs.NewWizardSelectionPage.advanceToNextPageOrFinish(NewWizardSelectionPage.java:71)
	at org.eclipse.ui.internal.dialogs.NewWizardNewPage$1.doubleClick(NewWizardNewPage.java:361)
	at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:833)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:50)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:173)
	at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:830)
	at org.eclipse.jface.viewers.AbstractTreeViewer.handleDoubleSelect(AbstractTreeViewer.java:1470)
	at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1264)
	at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:252)
	at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:249)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:311)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4248)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1501)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1524)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1509)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1313)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4072)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3698)
	at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
	at org.eclipse.jface.window.Window.open(Window.java:794)
	at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:269)
	at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:290)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:295)
	at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
	at sun.reflect.GeneratedMethodAccessor58.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:54)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:282)
	at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:264)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:132)
	at org.eclipse.e4.core.commands.internal.HandlerServiceHandler.execute(HandlerServiceHandler.java:152)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:494)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:488)
	at org.eclipse.e4.core.commands.internal.HandlerServiceImpl.executeHandler(HandlerServiceImpl.java:210)
	at org.eclipse.ui.internal.handlers.LegacyHandlerService.executeCommand(LegacyHandlerService.java:353)
	at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:155)
	at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:565)
	at org.eclipse.jface.action.ActionContributionItem.lambda$4(ActionContributionItem.java:397)
	at org.eclipse.jface.action.ActionContributionItem$$Lambda$37/1105286894.handleEvent(Unknown Source)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4248)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1501)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1524)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1509)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1313)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4072)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3698)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:687)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
Comment 71 Andrey Loskutov CLA 2016-09-02 14:29:27 EDT
(In reply to Andrey Loskutov - on the beach till 12.09 from comment #60)
> This is timing dependent issue, I think caused by the race conditions in
> DecorationScheduler. In my case I have GitLightweightDecorator (from EGit)
> and ResourceBugCountDecorator (from FindBugs) contributing the branch name
> and number if FB warnings to the project label. Disabling any one of the two
> fixes the problem immediately, disables both makes it appear pretty often
> (but still not in reproducible way!).
> 
> I imagine that the problem could be: timsort does few rounds,
> ViewerComparator computes text+decorations each time called (and can produce
> different labels for the same object!), so that timsort sees different
> results depending on the round => kaboom. 

Back to the issue I think the only reliable solution is to avoid using DecoratingLabelProvider in org.eclipse.jface.viewers.ViewerComparator.getLabel(Viewer, Object). I have a trivial patch.
Comment 72 Eclipse Genie CLA 2016-09-02 14:33:08 EDT
New Gerrit change created: https://git.eclipse.org/r/80327
Comment 73 Jacob Weber CLA 2016-09-06 15:19:14 EDT
In the meantime, is there any workaround? I can't create new files at this point.
Comment 74 Brian de Alwis CLA 2016-09-06 22:23:09 EDT
I think Andrey is right.  I've been able to reproduce this on OS X with the New > Folder with multiple EGit-based projects containing changed files.  The leading file-modified '>' marker will cause the sort order of an entry to change.

Jacob: have you tried adding `-Djava.util.Arrays.useLegacyMergeSort=true` to your launch?
Comment 75 Jacob Weber CLA 2016-09-07 12:59:34 EDT
Brian: that would make sense. When I launch Eclipse, I don't have the problem. But as soon as I right-click on a Git project, so the plugin gets loaded, it happens again.

Once I add -Djava.util.Arrays.useLegacyMergeSort=true to the end of my eclipse.ini and restart, I don't see the problem anymore.
Comment 77 Eclipse Genie CLA 2016-09-07 16:40:14 EDT
New Gerrit change created: https://git.eclipse.org/r/80630
Comment 78 Andrey Loskutov CLA 2016-09-07 16:42:52 EDT
(In reply to Eclipse Genie from comment #77)
> New Gerrit change created: https://git.eclipse.org/r/80630

I would like to backport this fix to 4.6.2. 
Any objections? If not, Brian, I need a second +1 for that.
Comment 79 Lars Vogel CLA 2016-09-08 03:26:02 EDT
As this might affect users, we should add this to the N&N M2 and document the new (temporary?) system property. 

I also suggest to open a follow bug to remove this system property in the next release, if no sorting issues are discovered.
Comment 80 Andrey Loskutov CLA 2016-09-08 03:37:23 EDT
(In reply to Lars Vogel from comment #79)
> As this might affect users, we should add this to the N&N M2 and document
> the new (temporary?) system property. 
> 
> I also suggest to open a follow bug to remove this system property in the
> next release, if no sorting issues are discovered.

Lars, can you do both? I have unbelievable slow internet connection here on the beach.
Comment 81 Lars Vogel CLA 2016-09-08 03:45:02 EDT
(In reply to Andrey Loskutov - on the beach till 12.09 from comment #80)

> Lars, can you do both?

Yes
Comment 82 Eclipse Genie CLA 2016-09-08 05:40:24 EDT
New Gerrit change created: https://git.eclipse.org/r/80675
Comment 83 Lars Vogel CLA 2016-09-08 05:45:36 EDT
(In reply to Lars Vogel from comment #81)
> > Lars, can you do both?

Done, please review the N&N
Comment 84 Brian de Alwis CLA 2016-09-08 09:43:15 EDT
+1 for backport to 4.6.2.  Thanks Andrey.
Comment 87 Andrey Loskutov CLA 2016-11-17 10:01:10 EST
Verified on Win 7 with build id: M20161116-1100 by looking on the source code of the ViewerComparator, since I can't reproduce the original issue.
Comment 88 Stéphane BARBARAY CLA 2022-06-21 04:54:30 EDT
Not resolved in 2022-06 and still forced to use the mentioned workaround property in eclipse.ini

I get exception

java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.base/java.util.TimSort.mergeHi(TimSort.java:903)
	at java.base/java.util.TimSort.mergeAt(TimSort.java:520)
	at java.base/java.util.TimSort.mergeCollapse(TimSort.java:448)
	at java.base/java.util.TimSort.sort(TimSort.java:245)
	at java.base/java.util.Arrays.sort(Arrays.java:1233)
	at org.eclipse.jface.viewers.TreePathViewerSorter.sort(TreePathViewerSorter.java:105)
	at org.eclipse.jface.viewers.AbstractTreeViewer.getSortedChildren(AbstractTreeViewer.java:657)
	at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:837)
	at org.eclipse.jface.viewers.TreeViewer.createChildren(TreeViewer.java:611)
	at org.eclipse.jface.viewers.AbstractTreeViewer.createChildren(AbstractTreeViewer.java:790)
	at org.eclipse.jface.viewers.AbstractTreeViewer.handleTreeExpand(AbstractTreeViewer.java:1565)
	at org.eclipse.jface.viewers.TreeViewer.handleTreeExpand(TreeViewer.java:897)
	at org.eclipse.jface.viewers.AbstractTreeViewer$3.treeExpanded(AbstractTreeViewer.java:1577)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:136)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4251)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1066)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1090)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1075)
	at org.eclipse.swt.widgets.Tree.wmNotifyChild(Tree.java:7625)
	at org.eclipse.swt.widgets.Control.wmNotify(Control.java:5800)
	at org.eclipse.swt.widgets.Composite.wmNotify(Composite.java:1961)
	at org.eclipse.swt.widgets.Control.WM_NOTIFY(Control.java:5368)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4802)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5026)
	at org.eclipse.swt.internal.win32.OS.CallWindowProc(Native Method)
	at org.eclipse.swt.widgets.Tree.callWindowProc(Tree.java:1542)
	at org.eclipse.swt.widgets.Tree.WM_LBUTTONDOWN(Tree.java:6527)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4782)
	at org.eclipse.swt.widgets.Tree.windowProc(Tree.java:6059)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:5026)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3643)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1155)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:156)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:152)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:136)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:402)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:659)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:596)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1467)


eclipse.buildId=4.24.0.I20220607-0700
java.version=17.0.2
java.vendor=Eclipse Adoptium
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=fr_FR
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product