This is an automated email from the ASF dual-hosted git repository.

Alanxtl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new 93fe03a49 fix(loadbalance): prevent panic in consistent hash toKey for 
non-string args (#3430)
93fe03a49 is described below

commit 93fe03a4962bb4f3e02e172141dd538df33be951
Author: aias00 <[email protected]>
AuthorDate: Wed Jun 17 13:41:10 2026 +0800

    fix(loadbalance): prevent panic in consistent hash toKey for non-string 
args (#3430)
    
    The hard type assertion args[i].(string) panics for any non-string
    argument (int, struct, etc.), while Java Dubbo uses toString() which
    never fails. Replace with fmt.Fprint(&sb, args[i]) which safely
    converts any type to its string representation.
---
 cluster/loadbalance/consistenthashing/selector.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cluster/loadbalance/consistenthashing/selector.go 
b/cluster/loadbalance/consistenthashing/selector.go
index 4ea278fd3..86808a85e 100644
--- a/cluster/loadbalance/consistenthashing/selector.go
+++ b/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])
                }
        }
        return sb.String()

Reply via email to