uyuni
uyuni copied to clipboard
Improve score comparison to avoid violating Comparator contract in System Search
What does this PR change?
This PR fixes the following error in system search: java.lang.IllegalArgumentException: Comparison method violates its general contract!
The previous approach used Math.abs(score1 - score2) < .001
to account for slight differences, which could lead to inconsistent results in certain situations. For example, if score1 is slightly less than score2 but within the .001 threshold, the method would treat them as equal. However, if score2 is compared to another score, score3, that is just slightly more than .001 greater than score1, the transitive property required by the general contract of compareTo
would be violated, leading to scenarios where A > B, B > C, and A < C, which is inconsistent.
GUI diff
No difference.
- [x] DONE
Documentation
-
No documentation needed: bug fix.
-
[x] DONE
Test coverage
ℹ️ If a major new functionality is added, it is strongly recommended that tests for the new functionality are added to the Cucumber test suite
-
No tests: add explanation
-
No tests: already covered
-
Unit tests were added
-
Cucumber tests were added
-
[x] DONE
Links
Issue(s): https://github.com/SUSE/spacewalk/issues/24953
- [ ] DONE
Changelogs
Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository
If you don't need a changelog check, please mark this checkbox:
- [ ] No changelog needed
If you uncheck the checkbox after the PR is created, you will need to re-run changelog_test
(see below)
Re-run a test
If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:
- [ ] Re-run test "changelog_test"
- [ ] Re-run test "backend_unittests_pgsql"
- [ ] Re-run test "java_pgsql_tests"
- [ ] Re-run test "schema_migration_test_pgsql"
- [ ] Re-run test "susemanager_unittests"
- [ ] Re-run test "javascript_lint"
- [ ] Re-run test "spacecmd_unittests"