Skip to content

Fix cluster slot calculation for String keys with DBCS charsets - #4697

Open
ansn366 wants to merge 1 commit into
redis:masterfrom
ansn366:codex/fix-string-cluster-slot-hashtag
Open

Fix cluster slot calculation for String keys with DBCS charsets#4697
ansn366 wants to merge 1 commit into
redis:masterfrom
ansn366:codex/fix-string-cluster-slot-hashtag

Conversation

@ansn366

@ansn366 ansn366 commented Aug 21, 2026

Copy link
Copy Markdown

Summary

  • Make JedisClusterCRC16.getSlot(String) delegate to the byte-array slot calculation after SafeEncoder encoding
  • Add a GBK regression test to ensure String and binary APIs compute the same cluster slot when encoded bytes contain hash tag delimiters

Fixes #4685.

Verification

  • Compiled the affected Jedis utility classes with JDK 8
  • Ran an offline GBK slot verification; result: OK 16212
  • Maven test command was attempted, but dependency download was blocked by the sandbox network policy

Note

Medium Risk
Touches cluster slot routing, so a mistake can send keys to the wrong node. The change is small and covered by a charset-specific test.

Overview
Fixes Redis Cluster slot calculation for String keys when a non-UTF-8 charset (e.g. GBK) is in use.

JedisClusterCRC16.getSlot(String) no longer extracts hash tags on Java characters. It encodes with SafeEncoder and reuses the byte-array path, so {/} are detected on the same bytes Redis would see. A GBK regression test checks String and binary APIs agree (slot 16212).

Reviewed by Cursor Bugbot for commit 3b86b5c. Bugbot is set up for automated code reviews on this repo. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cluster slot for String keys ignores byte-level hash tag under a DBCS default charset

1 participant