Skip to content

Commit 301e404

Browse files
committed
Fixes bzPopMaxShouldWorkCorrectly() and bzPopMinShouldWorkCorrectly() tests in JedisClusterConnectionTests.
Jedis 5.0 changed the bzpopmax and bzpopmin Redis commands to no longer return an empty (Array)List internally when evaluating and popping from an empty sorted set. A NullPointerException will be thrown if either bzpopmax or bzpopmin commands are executd on an empty Redis sorted set in Jedis 5.0 (vs. Jedis 4.x): Caused by: java.lang.NullPointerException: Cannot invoke 'java.util.List.isEmpty()' because l is null: at redis.clients.jedis.BuilderFactory7.build(BuilderFactory.java:616) This seems like a bug in Jedis. It is safe to execute zcard(key) to return the cardinality of (number of elements in) the sorted set before the test executes, ensuring a clean, reliable run. Closes spring-projects#2612
1 parent e091297 commit 301e404

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/test/java/org/springframework/data/redis/connection/jedis/JedisClusterConnectionTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,7 @@ public void zPopMinShouldWorkCorrectly() {
22792279
@EnabledOnCommand("BZPOPMIN")
22802280
public void bzPopMinShouldWorkCorrectly() {
22812281

2282-
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
2282+
assertThat(clusterConnection.zSetCommands().zCard(KEY_1_BYTES)).isZero();
22832283

22842284
nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES);
22852285
nativeConnection.zadd(KEY_1_BYTES, 20D, VALUE_2_BYTES);
@@ -2306,7 +2306,7 @@ public void zPopMaxShouldWorkCorrectly() {
23062306
@EnabledOnCommand("BZPOPMAX")
23072307
public void bzPopMaxShouldWorkCorrectly() {
23082308

2309-
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
2309+
assertThat(clusterConnection.zSetCommands().zCard(KEY_1_BYTES)).isZero();
23102310

23112311
nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES);
23122312
nativeConnection.zadd(KEY_1_BYTES, 20D, VALUE_2_BYTES);

0 commit comments

Comments
 (0)