This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 205828

Summary: IllegalArgumentException: Comparison method violates its general contract!
Product: platform Reporter: turneliusz
Component: Outline&TreeTableAssignee: Martin Entlicher <mentlicher>
Status: RESOLVED FIXED    
Severity: normal CC: mentlicher
Priority: P3 Keywords: API, API_REVIEW_FAST
Version: 7.2   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 183359
Attachments: stacktrace
Dump of variables
Screenshot
The file that can be used to reproduce this bug
The proposed API change that solves inconsistent values during sorting process..

Description turneliusz 2011-12-02 09:36:27 UTC
Build: NetBeans IDE Dev (Build 201111290600)
VM: Java HotSpot(TM) 64-Bit Server VM, 21.1-b02, Java(TM) SE Runtime Environment, 1.7.0_01-b08
OS: Windows 7

User Comments:
turneliusz: debugging, "variables" tab, sorting by value




Stacktrace: 
java.lang.IllegalArgumentException: Comparison method violates its general contract!
   at java.util.TimSort.mergeHi(TimSort.java:0)
   at java.util.TimSort.mergeAt(TimSort.java:0)
   at java.util.TimSort.mergeCollapse(TimSort.java:0)
   at java.util.TimSort.sort(TimSort.java:0)
   at java.util.TimSort.sort(TimSort.java:0)
   at java.util.Arrays.sort(Arrays.java:0)
Comment 1 turneliusz 2011-12-02 09:36:30 UTC
Created attachment 113739 [details]
stacktrace
Comment 2 turneliusz 2011-12-02 11:09:53 UTC
Created attachment 113748 [details]
Dump of variables
Comment 3 turneliusz 2011-12-02 11:10:07 UTC
Created attachment 113750 [details]
Screenshot
Comment 4 Martin Entlicher 2011-12-02 12:41:10 UTC
Thanks for the dump of variables, we'll hopefully reproduce it with them...
Comment 5 Martin Entlicher 2011-12-16 10:53:56 UTC
*** Bug 206473 has been marked as a duplicate of this bug. ***
Comment 6 Martin Entlicher 2011-12-16 10:56:17 UTC
Created attachment 114260 [details]
The file that can be used to reproduce this bug

I've successfully reproduced this bug on the provided data.
Comment 7 Martin Entlicher 2011-12-16 12:56:14 UTC
The bug is caused by items that do not manage to evaluate fast enough and return "Evaluating..." value until the real value is retrieved.
This corrupts the sorting in cases when a variable returns "Evaluating..." during one comparison and the real value during another comparison. This breaks the consistency.
The fix should be to make sure that all variables are fully evaluated before the sorting takes place and also to assure that the variable values can not change until the sorting is finished.
Comment 8 Martin Entlicher 2011-12-16 19:09:11 UTC
Created attachment 114276 [details]
The proposed API change that solves inconsistent values during sorting process..
Comment 9 Martin Entlicher 2011-12-16 19:11:28 UTC
Please review the attached simple API change that allows to cache the transformed model values during the sorting process. The caching assures that the data can not change during sorting.
Comment 10 Martin Entlicher 2011-12-16 19:24:02 UTC
FYI: This change solves the exception, but some rows may end up unsorted (those that happen to get the "Evaluating..." text). To solve the sorting in this case, I've submitted issue #206486.
Comment 11 Quality Engineering 2011-12-20 15:56:43 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/868ebc55a4b5
User: mentlicher@netbeans.org
Log: #205828 Make the comparison symmetric.
Comment 12 Martin Entlicher 2012-01-02 13:04:57 UTC
Thanks for the review, the fix is pushed as changeset:   209630:8c344093bcfa
http://hg.netbeans.org/main/rev/8c344093bcfa
Comment 13 Quality Engineering 2012-01-03 15:44:08 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/8c344093bcfa
User: mentlicher@netbeans.org
Log: #205828 RowMapping.getTransformedValue() method is introduced to assure that we retrieve every cell value only once per any number of calls.