skt-shinyruo commented on code in PR #16306:
URL: https://github.com/apache/dubbo/pull/16306#discussion_r3346483111


##########
dubbo-common/src/main/java/org/apache/dubbo/common/utils/CollectionUtils.java:
##########
@@ -429,6 +429,15 @@ public static <T> Set<T> toTreeSet(Set<T> set) {
         return set;
     }
 
+    public static <T> Set<T> toTreeSet(Set<T> set, Comparator<? super T> 
comparator) {
+        if (set == null) {

Review Comment:
   The null check is intentional here. For this comparator overload, null and 
empty inputs need different handling: null keeps the existing null-return 
behavior, while an empty non-null set should still return an empty TreeSet 
initialized with the provided comparator. Returning the original set from 
isEmpty(set) would lose that comparator. The addAll call is a no-op for an 
empty set.
   
   I also added a null-input test for this overload in 630215ff94.



-- 
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]

Reply via email to