Fix CRC16 encode : string to bytes
* should use SafeEncoder.encode() instead of String.getBytes()
This commit is contained in:
@@ -59,7 +59,7 @@ public class JedisClusterCRC16 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static int getCRC16(String key) {
|
public static int getCRC16(String key) {
|
||||||
return getCRC16(key.getBytes());
|
return getCRC16(SafeEncoder.encode(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ import java.util.Map.Entry;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import redis.clients.util.JedisClusterCRC16;
|
import redis.clients.util.JedisClusterCRC16;
|
||||||
|
import redis.clients.util.SafeEncoder;
|
||||||
|
|
||||||
public class JedisClusterCRC16Test {
|
public class JedisClusterCRC16Test {
|
||||||
|
|
||||||
@@ -21,7 +22,7 @@ public class JedisClusterCRC16Test {
|
|||||||
assertEquals(entry.getValue().intValue(), JedisClusterCRC16.getCRC16(entry.getKey()));
|
assertEquals(entry.getValue().intValue(), JedisClusterCRC16.getCRC16(entry.getKey()));
|
||||||
|
|
||||||
// byte array version
|
// byte array version
|
||||||
assertEquals(entry.getValue().intValue(), JedisClusterCRC16.getCRC16(entry.getKey().getBytes()));
|
assertEquals(entry.getValue().intValue(), JedisClusterCRC16.getCRC16(SafeEncoder.encode(entry.getKey())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user