Issue #158 is fixed: Response.get() returns null if redis returned null (i.e. when using zscore for a non existing member)
This commit is contained in:
@@ -24,10 +24,12 @@ public class Response<T> {
|
||||
"Please close pipeline or multi block before calling this method.");
|
||||
}
|
||||
if (!built) {
|
||||
if (data instanceof JedisDataException){
|
||||
throw new JedisDataException((JedisDataException)data);
|
||||
if(data != null ){
|
||||
if (data instanceof JedisDataException){
|
||||
throw new JedisDataException((JedisDataException)data);
|
||||
}
|
||||
response = builder.build(data);
|
||||
}
|
||||
response = builder.build(data);
|
||||
this.data = null;
|
||||
built = true;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,29 @@ public class PipeliningTest extends Assert {
|
||||
assertEquals(1, smembers.get().size());
|
||||
assertEquals(1, zrangeWithScores.get().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pipelineResponseWithData() {
|
||||
jedis.zadd("zset", 1, "foo");
|
||||
|
||||
Pipeline p = jedis.pipelined();
|
||||
Response<Double> score = p.zscore("zset", "foo");
|
||||
p.sync();
|
||||
|
||||
assertNotNull(score.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pipelineResponseWithoutData() {
|
||||
jedis.zadd("zset", 1, "foo");
|
||||
|
||||
Pipeline p = jedis.pipelined();
|
||||
Response<Double> score = p.zscore("zset", "bar");
|
||||
p.sync();
|
||||
|
||||
assertNull(score.get());
|
||||
}
|
||||
|
||||
|
||||
@Test(expected = JedisDataException.class)
|
||||
public void pipelineResponseWithinPipeline() {
|
||||
|
||||
Reference in New Issue
Block a user