skt-shinyruo opened a new pull request, #16306: URL: https://github.com/apache/dubbo/pull/16306
## What is the purpose of the change? GitHub_issue: Fixes #16297 This pull request improves the type safety of `CollectionUtils.toTreeSet`. The existing single-argument overload accepted any `Set<T>`, but its implementation delegates to `TreeSet`, which requires naturally comparable elements unless a comparator is provided. The updated signature makes that requirement explicit at compile time: ```java public static <T extends Comparable<? super T>> Set<T> toTreeSet(Set<T> set) ``` This pull request also adds a comparator-based overload for custom ordering and non-`Comparable` element types: ```java public static <T> Set<T> toTreeSet(Set<T> set, Comparator<? super T> comparator) ``` For non-null empty inputs, the comparator overload returns an empty `TreeSet` that preserves the provided comparator. Verification: - `mvn -pl dubbo-common -Dtest=CollectionUtilsTest test` - `git diff --check` ## Checklist - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] 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](https://github.com/apache/dubbo-samples) project. - [x] Make sure gitHub actions can pass. [Why the workflow is failing and how to fix it?](../CONTRIBUTING.md) -- 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]
