Fix potential NullPointerException when using Jedis Cluster BZPOP*.
For the Jedis-based implementations of bzpopmin and bzpopmax, a NPE is thrown if the provided timeout elapses and the server responds with a null array. Closes #2324
This commit is contained in:
@@ -1256,7 +1256,7 @@ class JedisClusterZSetCommands implements RedisZSetCommands {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Tuple toTuple(List<?> bytes) {
|
||||
|
||||
if (bytes.isEmpty()) {
|
||||
if (bytes == null || bytes.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2155,6 +2155,9 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
@EnabledOnCommand("BZPOPMIN")
|
||||
public void bzPopMinShouldWorkCorrectly() {
|
||||
|
||||
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS))
|
||||
.isNull();
|
||||
|
||||
nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES);
|
||||
nativeConnection.zadd(KEY_1_BYTES, 20D, VALUE_2_BYTES);
|
||||
nativeConnection.zadd(KEY_1_BYTES, 30D, VALUE_3_BYTES);
|
||||
@@ -2180,6 +2183,9 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
@EnabledOnCommand("BZPOPMAX")
|
||||
public void bzPopMaxShouldWorkCorrectly() {
|
||||
|
||||
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS))
|
||||
.isNull();
|
||||
|
||||
nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES);
|
||||
nativeConnection.zadd(KEY_1_BYTES, 20D, VALUE_2_BYTES);
|
||||
nativeConnection.zadd(KEY_1_BYTES, 30D, VALUE_3_BYTES);
|
||||
|
||||
Reference in New Issue
Block a user