throw JedisDataException when sending NULL values to redis as it is not a valid value in the protocol
This commit is contained in:
@@ -3,6 +3,7 @@ package redis.clients.util;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import redis.clients.jedis.Protocol;
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
|
||||
/**
|
||||
@@ -12,6 +13,10 @@ import redis.clients.jedis.exceptions.JedisException;
|
||||
public class SafeEncoder {
|
||||
public static byte[] encode(final String str) {
|
||||
try {
|
||||
if (str == null) {
|
||||
throw new JedisDataException(
|
||||
"value sent to redis cannot be null");
|
||||
}
|
||||
return str.getBytes(Protocol.CHARSET);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new JedisException(e);
|
||||
|
||||
Reference in New Issue
Block a user