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:
ivos
2011-12-14 05:43:52 +01:00
committed by Jonathan Leibiusky
parent b17692ad9a
commit f3a5d62e2b
2 changed files with 28 additions and 3 deletions

View File

@@ -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;
}

View File

@@ -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() {