Skip to content

Commit 4144b45

Browse files
committed
Polishing.
Add author tags. Align Lettuce BZPOPMIN/MAX tests. Increase timeout to 10ms as Redis blocks indefinitely if the timeout is less than 0.01. See #2324
1 parent 9af6082 commit 4144b45

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
* @author Mark Paluch
4444
* @author Clement Ong
4545
* @author Andrey Shlykov
46+
* @author Jens Deppe
4647
* @since 2.0
4748
*/
4849
class JedisClusterZSetCommands implements RedisZSetCommands {
@@ -1254,7 +1255,7 @@ private static ZParams toZParams(Aggregate aggregate, Weights weights) {
12541255
*/
12551256
@Nullable
12561257
@SuppressWarnings("unchecked")
1257-
private static Tuple toTuple(List<?> bytes) {
1258+
private static Tuple toTuple(@Nullable List<?> bytes) {
12581259

12591260
if (bytes == null || bytes.isEmpty()) {
12601261
return null;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
6767
import org.springframework.data.redis.connection.ReturnType;
6868
import org.springframework.data.redis.connection.ValueEncoding.RedisValueEncoding;
69-
import org.springframework.data.redis.connection.RedisListCommands.*;
7069
import org.springframework.data.redis.core.Cursor;
7170
import org.springframework.data.redis.core.ScanOptions;
7271
import org.springframework.data.redis.core.script.DigestUtils;
@@ -2277,7 +2276,7 @@ public void zPopMinShouldWorkCorrectly() {
22772276
@EnabledOnCommand("BZPOPMIN")
22782277
public void bzPopMinShouldWorkCorrectly() {
22792278

2280-
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS))
2279+
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS))
22812280
.isNull();
22822281

22832282
nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES);
@@ -2305,7 +2304,7 @@ public void zPopMaxShouldWorkCorrectly() {
23052304
@EnabledOnCommand("BZPOPMAX")
23062305
public void bzPopMaxShouldWorkCorrectly() {
23072306

2308-
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS))
2307+
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS))
23092308
.isNull();
23102309

23112310
nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES);

src/test/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnectionTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,10 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
9393
private static final GeoLocation<String> PALERMO = new GeoLocation<>("palermo", POINT_PALERMO);
9494

9595
private static final GeoLocation<byte[]> ARIGENTO_BYTES = new GeoLocation<>(
96-
"arigento".getBytes(StandardCharsets.UTF_8),
97-
POINT_ARIGENTO);
98-
private static final GeoLocation<byte[]> CATANIA_BYTES = new GeoLocation<>(
99-
"catania".getBytes(StandardCharsets.UTF_8),
96+
"arigento".getBytes(StandardCharsets.UTF_8), POINT_ARIGENTO);
97+
private static final GeoLocation<byte[]> CATANIA_BYTES = new GeoLocation<>("catania".getBytes(StandardCharsets.UTF_8),
10098
POINT_CATANIA);
101-
private static final GeoLocation<byte[]> PALERMO_BYTES = new GeoLocation<>(
102-
"palermo".getBytes(StandardCharsets.UTF_8),
99+
private static final GeoLocation<byte[]> PALERMO_BYTES = new GeoLocation<>("palermo".getBytes(StandardCharsets.UTF_8),
103100
POINT_PALERMO);
104101

105102
private final RedisClusterClient client;
@@ -179,7 +176,6 @@ void shouldCreateClusterConnectionWithPooling() {
179176
factory.destroy();
180177
}
181178

182-
183179
@Test // DATAREDIS-315
184180
public void appendShouldAddValueCorrectly() {
185181

@@ -2315,6 +2311,8 @@ public void zPopMinShouldWorkCorrectly() {
23152311
@EnabledOnCommand("BZPOPMIN")
23162312
public void bzPopMinShouldWorkCorrectly() {
23172313

2314+
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
2315+
23182316
nativeConnection.zadd(KEY_1, 10D, VALUE_1);
23192317
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
23202318
nativeConnection.zadd(KEY_1, 30D, VALUE_3);
@@ -2327,6 +2325,8 @@ public void bzPopMinShouldWorkCorrectly() {
23272325
@EnabledOnCommand("ZPOPMAX")
23282326
public void zPopMaxShouldWorkCorrectly() {
23292327

2328+
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
2329+
23302330
nativeConnection.zadd(KEY_1, 10D, VALUE_1);
23312331
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
23322332
nativeConnection.zadd(KEY_1, 30D, VALUE_3);
@@ -2498,8 +2498,8 @@ public void zRangeWithScoresShouldReturnValuesAndScoreCorrectly() {
24982498
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
24992499
nativeConnection.zadd(KEY_1, 5D, VALUE_3);
25002500

2501-
assertThat(clusterConnection.zRangeWithScores(KEY_1_BYTES, 1, 2))
2502-
.contains(new DefaultTuple(VALUE_1_BYTES, 10D), new DefaultTuple(VALUE_2_BYTES, 20D));
2501+
assertThat(clusterConnection.zRangeWithScores(KEY_1_BYTES, 1, 2)).contains(new DefaultTuple(VALUE_1_BYTES, 10D),
2502+
new DefaultTuple(VALUE_2_BYTES, 20D));
25032503
}
25042504

25052505
@Test // DATAREDIS-315
@@ -2616,8 +2616,8 @@ public void zRevRangeWithScoresShouldReturnValuesAndScoreCorrectly() {
26162616
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
26172617
nativeConnection.zadd(KEY_1, 5D, VALUE_3);
26182618

2619-
assertThat(clusterConnection.zRevRangeWithScores(KEY_1_BYTES, 1, 2))
2620-
.contains(new DefaultTuple(VALUE_3_BYTES, 5D), new DefaultTuple(VALUE_1_BYTES, 10D));
2619+
assertThat(clusterConnection.zRevRangeWithScores(KEY_1_BYTES, 1, 2)).contains(new DefaultTuple(VALUE_3_BYTES, 5D),
2620+
new DefaultTuple(VALUE_1_BYTES, 10D));
26212621
}
26222622

26232623
@Test

0 commit comments

Comments
 (0)