Copilot commented on code in PR #3186:
URL: https://github.com/apache/dubbo-go/pull/3186#discussion_r2749404420


##########
cluster/router/condition/dynamic_router.go:
##########
@@ -382,13 +388,13 @@ func (a *ApplicationRouter) Notify(invokers 
[]base.Invoker) {
        }
 }
 
-func removeDuplicates(rules []*config.ConditionRule) {
+func removeDuplicates(rules []*global.ConditionRule) {
        for i := 0; i < len(rules); i++ {
                if rules[i] == nil {
                        continue
                }
                for j := i + 1; j < len(rules); j++ {
-                       if rules[j] != nil && rules[i].Equal(rules[j]) {
+                       if rules[j] != nil && reflect.DeepEqual(rules[i], 
rules[j]) {
                                rules[j] = nil
                        }

Review Comment:
   removeDuplicates previously used config.ConditionRule.Equal, which treats 
nil and empty To slices as equal (it compares len(To)). Switching to 
reflect.DeepEqual changes semantics: a rule with To=nil will not be considered 
equal to the same rule with To=[] and duplicates may remain. Consider 
reintroducing an explicit equality helper that matches the old behavior 
(compare From, compare len(To), then compare each To element) instead of 
reflect.DeepEqual.



##########
cluster/router/condition/route.go:
##########
@@ -439,7 +439,7 @@ func NewConditionMultiDestRouter(url *common.URL) 
(*MultiDestRouter, error) {
        if !ok {
                return nil, errors.Errorf("Condition Router can't get the rule 
key")
        }
-       condConf, ok := rawCondConf.(*config.ConditionRule)
+       condConf, ok := rawCondConf.(*global.ConditionRule)
        if !ok {
                return nil, errors.Errorf("Condition Router get the rule key 
invaild , got %T", rawCondConf)

Review Comment:
   Typo in error message: "invaild" should be "invalid" (and ideally keep 
messages consistent across routers).
   ```suggestion
                return nil, errors.Errorf("Condition Router get the rule key 
invalid , got %T", rawCondConf)
   ```



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