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

Bug 311517

Summary: builder ordering algorithm gives wrong results
Product: [Modeling] MoDisco Reporter: Nicolas Bros <nicolas.bros>
Component: InfrastructureAssignee: Nicolas Bros <nicolas.bros>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: gdupe, hugo.bruneliere, modisco.web-inbox
Version: 0.8.0   
Target Milestone: 0.8.0   
Hardware: All   
OS: All   
Whiteboard:

Description Nicolas Bros CLA 2010-05-04 07:43:34 EDT
While debugging, I found out that the customization builder appeared before all the other builders in the list of builders, which is supposed to be ordered by dependency. It should be last in this list, since it depends on the ecore, query and facet builders.

The ModiscoProjectBuilder.BuilderDescriptor#compareTo method gives those results (where C=customization builder, E=ecore builder, etc.):

C = E, E < F, F > Q, E < Q, F = J

The resulting list is C,E,Q,F,J, which is consistent with the results returned by compare.

The problem lies in the fact that compare returns 0 (meaning equal) for 2 builders that are independent, but not equal, hereby breaking the contract of "Comparable".

In fact, depending on the sorting algorithm (quick sort, insertion sort, etc.), the result can be different.
Comment 1 Nicolas Bros CLA 2010-05-04 08:27:28 EDT
Fixed in revision 2188, by using a different algorithm for sorting:
first add builders that depend on nothing to a list, then those that depend only on those already in the list, etc.
Comment 2 Hugo Bruneliere CLA 2010-10-01 13:35:06 EDT
Bug fixed.