Copilot commented on code in PR #3430:
URL: https://github.com/apache/dubbo-go/pull/3430#discussion_r3425334858
##########
cluster/loadbalance/consistenthashing/selector.go:
##########
@@ -85,7 +85,7 @@ func (c *selector) toKey(args []any) string {
var sb strings.Builder
for i := range c.argumentIndex {
if i >= 0 && i < len(args) {
- _, _ = fmt.Fprint(&sb, args[i].(string))
+ _, _ = fmt.Fprint(&sb, args[i])
}
}
Review Comment:
`fmt.Fprint(&sb, args[i])` changes key semantics in a way that can produce
nondeterministic or ambiguous consistent-hash keys. For example, pointer
arguments may stringify to addresses (varying between runs), and concatenating
multiple arguments without a delimiter can cause collisions (e.g., ["ab","c"]
vs ["a","bc"]). To keep hashing stable and collision-resistant, consider using
a deterministic, delimited encoding per argument (and/or restricting accepted
argument types to those with stable string forms).
--
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]