Pipeline commands should not throw an exception when a key is unset
This commit is contained in:
@@ -1,16 +1,9 @@
|
||||
package redis.clients.jedis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.util.SafeEncoder;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class BuilderFactory {
|
||||
public static final Builder<Double> DOUBLE = new Builder<Double>() {
|
||||
public Double build(Object data) {
|
||||
@@ -52,7 +45,7 @@ public class BuilderFactory {
|
||||
};
|
||||
public static final Builder<String> STRING = new Builder<String>() {
|
||||
public String build(Object data) {
|
||||
return SafeEncoder.encode((byte[]) data);
|
||||
return data == null ? null : SafeEncoder.encode((byte[]) data);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
package redis.clients.jedis.tests;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import redis.clients.jedis.*;
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
import redis.clients.jedis.tests.HostAndPortUtil.HostAndPort;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.Pipeline;
|
||||
import redis.clients.jedis.PipelineBlock;
|
||||
import redis.clients.jedis.Response;
|
||||
import redis.clients.jedis.Tuple;
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
import redis.clients.jedis.tests.HostAndPortUtil.HostAndPort;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PipeliningTest extends Assert {
|
||||
private static HostAndPort hnp = HostAndPortUtil.getRedisServers().get(0);
|
||||
@@ -114,4 +110,12 @@ public class PipeliningTest extends Assert {
|
||||
assertEquals(0, p1.get().longValue());
|
||||
assertEquals(0, p2.get().longValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canRetrieveUnsetKey() {
|
||||
Pipeline p = jedis.pipelined();
|
||||
Response<String> shouldNotExist = p.get(UUID.randomUUID().toString());
|
||||
p.sync();
|
||||
assertNull(shouldNotExist.get());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user