codingkiddo opened a new issue, #16235: URL: https://github.com/apache/dubbo/issues/16235
### Pre-check - [x] I am sure that all the content I provide is in English. ### Search before asking - [x] I had searched in the [issues](https://github.com/apache/dubbo/issues?q=is%3Aissue) and found no similar issues. ### Apache Dubbo Component Java SDK (apache/dubbo) ### Dubbo Version Dubbo - 3.3, JDK - 21, OS - MacOS(26.3.1 (a) (25D771280a)) ### Steps to reproduce this issue Improve generic type safety of CollectionUtils.sort ### What you expected to happen ### Motivation `CollectionUtils.sort` currently accepts any `List<T>` and internally calls `Collections.sort` using a raw cast / suppressed warnings. This allows code like `CollectionUtils.sort(List<NonComparableType>)` to compile, but it may fail at runtime because natural ordering requires elements to implement `Comparable`. ### Proposed change Change the method signature from: ```java public static <T> List<T> sort(List<T> list) ``` to ```java public static <T extends Comparable<? super T>> List<T> sort(List<T> list) ``` and remove the raw cast ```java Collections.sort(list); ``` ### Anything else This aligns the method with java.util.Collections.sort, improves compile-time type safety, and preserves the original return type List<T>. ### Do you have a (mini) reproduction demo? - [ ] Yes, I have a minimal reproduction demo to help resolve this issue more effectively! ### Are you willing to submit a pull request to fix on your own? - [x] Yes I am willing to submit a pull request on my own! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
