Skip to content

Commit 7469ce0

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 c8f4d0c commit 7469ce0

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
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
@@ -48,6 +48,7 @@
4848
* @author Mark Paluch
4949
* @author Clement Ong
5050
* @author Andrey Shlykov
51+
* @author Jens Deppe
5152
* @since 2.0
5253
*/
5354
class JedisClusterZSetCommands implements RedisZSetCommands {
@@ -1042,7 +1043,7 @@ private static ZParams toZParams(Aggregate aggregate, Weights weights) {
10421043
*/
10431044
@Nullable
10441045
@SuppressWarnings("unchecked")
1045-
private static Tuple toTuple(List<?> bytes) {
1046+
private static Tuple toTuple(@Nullable List<?> bytes) {
10461047

10471048
if (bytes == null || bytes.isEmpty()) {
10481049
return null;

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

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

2283-
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS))
2284-
.isNull();
2283+
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
22852284

22862285
nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES);
22872286
nativeConnection.zadd(KEY_1_BYTES, 20D, VALUE_2_BYTES);
@@ -2308,8 +2307,7 @@ public void zPopMaxShouldWorkCorrectly() {
23082307
@EnabledOnCommand("BZPOPMAX")
23092308
public void bzPopMaxShouldWorkCorrectly() {
23102309

2311-
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS))
2312-
.isNull();
2310+
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
23132311

23142312
nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES);
23152313
nativeConnection.zadd(KEY_1_BYTES, 20D, VALUE_2_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
@@ -97,13 +97,10 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
9797
private static final GeoLocation<String> PALERMO = new GeoLocation<>("palermo", POINT_PALERMO);
9898

9999
private static final GeoLocation<byte[]> ARIGENTO_BYTES = new GeoLocation<>(
100-
"arigento".getBytes(StandardCharsets.UTF_8),
101-
POINT_ARIGENTO);
102-
private static final GeoLocation<byte[]> CATANIA_BYTES = new GeoLocation<>(
103-
"catania".getBytes(StandardCharsets.UTF_8),
100+
"arigento".getBytes(StandardCharsets.UTF_8), POINT_ARIGENTO);
101+
private static final GeoLocation<byte[]> CATANIA_BYTES = new GeoLocation<>("catania".getBytes(StandardCharsets.UTF_8),
104102
POINT_CATANIA);
105-
private static final GeoLocation<byte[]> PALERMO_BYTES = new GeoLocation<>(
106-
"palermo".getBytes(StandardCharsets.UTF_8),
103+
private static final GeoLocation<byte[]> PALERMO_BYTES = new GeoLocation<>("palermo".getBytes(StandardCharsets.UTF_8),
107104
POINT_PALERMO);
108105

109106
private final RedisClusterClient client;
@@ -183,7 +180,6 @@ void shouldCreateClusterConnectionWithPooling() {
183180
factory.destroy();
184181
}
185182

186-
187183
@Test // DATAREDIS-315
188184
public void appendShouldAddValueCorrectly() {
189185

@@ -2320,6 +2316,8 @@ public void zPopMinShouldWorkCorrectly() {
23202316
@EnabledOnCommand("BZPOPMIN")
23212317
public void bzPopMinShouldWorkCorrectly() {
23222318

2319+
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
2320+
23232321
nativeConnection.zadd(KEY_1, 10D, VALUE_1);
23242322
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
23252323
nativeConnection.zadd(KEY_1, 30D, VALUE_3);
@@ -2332,6 +2330,8 @@ public void bzPopMinShouldWorkCorrectly() {
23322330
@EnabledOnCommand("ZPOPMAX")
23332331
public void zPopMaxShouldWorkCorrectly() {
23342332

2333+
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
2334+
23352335
nativeConnection.zadd(KEY_1, 10D, VALUE_1);
23362336
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
23372337
nativeConnection.zadd(KEY_1, 30D, VALUE_3);
@@ -2504,8 +2504,8 @@ public void zRangeWithScoresShouldReturnValuesAndScoreCorrectly() {
25042504
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
25052505
nativeConnection.zadd(KEY_1, 5D, VALUE_3);
25062506

2507-
assertThat(clusterConnection.zRangeWithScores(KEY_1_BYTES, 1, 2))
2508-
.contains(new DefaultTuple(VALUE_1_BYTES, 10D), new DefaultTuple(VALUE_2_BYTES, 20D));
2507+
assertThat(clusterConnection.zRangeWithScores(KEY_1_BYTES, 1, 2)).contains(new DefaultTuple(VALUE_1_BYTES, 10D),
2508+
new DefaultTuple(VALUE_2_BYTES, 20D));
25092509
}
25102510

25112511
@Test // DATAREDIS-315
@@ -2622,8 +2622,8 @@ public void zRevRangeWithScoresShouldReturnValuesAndScoreCorrectly() {
26222622
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
26232623
nativeConnection.zadd(KEY_1, 5D, VALUE_3);
26242624

2625-
assertThat(clusterConnection.zRevRangeWithScores(KEY_1_BYTES, 1, 2))
2626-
.contains(new DefaultTuple(VALUE_3_BYTES, 5D), new DefaultTuple(VALUE_1_BYTES, 10D));
2625+
assertThat(clusterConnection.zRevRangeWithScores(KEY_1_BYTES, 1, 2)).contains(new DefaultTuple(VALUE_3_BYTES, 5D),
2626+
new DefaultTuple(VALUE_1_BYTES, 10D));
26272627
}
26282628

26292629
@Test

0 commit comments

Comments
 (0)