Skip to content

Require comparable elements for CollectionUtils.sort#16257

Closed
mike-lmctl wants to merge 1 commit intoapache:3.3from
mike-lmctl:require-comparable-for-collection-sort
Closed

Require comparable elements for CollectionUtils.sort#16257
mike-lmctl wants to merge 1 commit intoapache:3.3from
mike-lmctl:require-comparable-for-collection-sort

Conversation

@mike-lmctl
Copy link
Copy Markdown

What is the purpose of the change?

GitHub_issue: #16235

CollectionUtils.sort delegates to Collections.sort, but its generic
signature did not require comparable elements. This adds the same
Comparable bound and removes the raw cast, so invalid callers fail at
compile time instead of at runtime.

The existing sort tests still pass, and the affected cluster module compiles
with the stricter signature.

Tests:

./mvnw -pl dubbo-common -Dtest=CollectionUtilsTest#testSort+testSortNull test
./mvnw -pl dubbo-cluster -am -DskipTests compile

Checklist

  • Make sure there is a GitHub_issue field for the change.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Write necessary unit-test to verify your logic correction. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Make sure gitHub actions can pass. Why the workflow is failing and how to fix it?

CollectionUtils.sort delegates to Collections.sort, but its generic signature
did not expose the natural-ordering requirement. That let callers pass a list
whose element type was not comparable and defer the failure to runtime.

Add the same Comparable bound used by Collections.sort and remove the raw cast.

Tested: ./mvnw -pl dubbo-common -Dtest=CollectionUtilsTest#testSort+testSortNull test
Tested: ./mvnw -pl dubbo-cluster -am -DskipTests compile
Signed-off-by: Mike Ma <mike.ma@lmctl.com>
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.80%. Comparing base (6916d1b) to head (d3bf989).

Additional details and impacted files
@@             Coverage Diff              @@
##                3.3   #16257      +/-   ##
============================================
+ Coverage     60.78%   60.80%   +0.02%     
- Complexity    11763    11769       +6     
============================================
  Files          1953     1953              
  Lines         89186    89186              
  Branches      13454    13454              
============================================
+ Hits          54209    54232      +23     
+ Misses        29400    29384      -16     
+ Partials       5577     5570       -7     
Flag Coverage Δ
integration-tests-java21 32.15% <100.00%> (-0.01%) ⬇️
integration-tests-java8 32.24% <100.00%> (+0.01%) ⬆️
samples-tests-java21 32.16% <0.00%> (-0.04%) ⬇️
samples-tests-java8 29.78% <0.00%> (-0.04%) ⬇️
unit-tests-java11 59.01% <100.00%> (-0.01%) ⬇️
unit-tests-java17 58.52% <100.00%> (+0.01%) ⬆️
unit-tests-java21 58.50% <100.00%> (-0.01%) ⬇️
unit-tests-java25 58.47% <100.00%> (+<0.01%) ⬆️
unit-tests-java8 59.00% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zrlw
Copy link
Copy Markdown
Contributor

zrlw commented May 8, 2026

Duplicated with #16236

@zrlw zrlw closed this May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants