-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Cannot scan binary keys with Jedis #2006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We could switch |
Interesting, I hadn't considered the globbing implications. How does that comport with the implementation of [1] https://github.com/spring-projects/spring-data-redis/blob/master/src/main/java/org/springframework/data/redis/connection/jedis/JedisSetCommands.java#L275 |
For |
We now accept a byte array as pattern for scan operations in addition to String patterns. Also, use binary Jedis scan method to avoid bytes to String conversion. Closes #2006
We now accept a byte array as pattern for scan operations in addition to String patterns. Also, use binary Jedis scan method to avoid bytes to String conversion. Closes #2006
In
org.springframework.data:spring-data-redis:2.4.5
, inorg.springframework.data.redis.connection.jedis.JedisKeyCommands#scan(long, org.springframework.data.redis.core.ScanOptions)
[1] we round trip keys throughString
, corrupting them. This makes it impossible scan top level keys using Jedis.Specifically, we call
redis.clients.jedis.Jedis#scan(java.lang.String, redis.clients.jedis.ScanParams)
which decodes keys as strings, interpreting the binary data as UTF-8. On the next line, we encode the strings back into byte arrays usingJedisConverters.stringListToByteList()
, which renders UTF-8 again. This generally results in any non-UTF-8 sequences in a binary key being replaced withefbfbd
(the UTF-8 serialization of the Unicode replacement character).Instead, we should call
redis.clients.jedis.BinaryJedis#scan(byte[], redis.clients.jedis.ScanParams)
and remove the second conversion usingJedisConverters.stringListToByteList()
.[1] https://github.com/spring-projects/spring-data-redis/blob/master/src/main/java/org/springframework/data/redis/connection/jedis/JedisKeyCommands.java#L159
The text was updated successfully, but these errors were encountered: