-
-
Notifications
You must be signed in to change notification settings - Fork 302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CapabilityComparator.compare violates contract #5793
Comments
It' more complicated. The CapabilityComparator does not ensure the transitivity of the relation ("The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0."). I've used this simple check (added to the code before the sorting in AbstractResolverContext.java:270). It inserts each element into a sorted list, checking that not only the element at the insertion point but also all subsequent elements are "greater" than the element to be inserted.
Here's an example of a failure:
The comparator considers the element shown next (already in the list at index 11) to be "greater" (because the bundle version is lower):
However, the element shown next (which appears later in the list) is "smaller" than the element to be inserted, thus violating the assumption that everything beyond the bigger element at the insertion point must be bigger than the element to be inserted (note the difference in the bundle-symbolic-name):
While these differences won't break simple sorting algorithms (just for the record: I do know that there are better ones than creating a sorted list), this inconsistency makes Timsort fail. |
The comparator is as far as I can see having at least 4 or 5 serious bugs. I will fix this. |
Fixed in #5807 |
When running the resolver (bnd 6.4.0), I sometimes get
I've added this simple code to find out which capabilities cause the problem:
As it turns out, the capabilities causing the problem are
osgi.ee;osgi.ee='JavaSE/compact1';version:Version='1.8.0'
andosgi.ee;osgi.ee=JavaSE;version:Version='1.7.0'
. The comparator returns inconsistent results when the arguments are swapped.Knowing the resources, the problem is quite obvious:
If both arguments are framework bundles, the first is always considered smaller
The text was updated successfully, but these errors were encountered: