Skip to content

Commit 515cec6

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 1923978 commit 515cec6

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
@@ -65,7 +65,6 @@
6565
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
6666
import org.springframework.data.redis.connection.ReturnType;
6767
import org.springframework.data.redis.connection.ValueEncoding.RedisValueEncoding;
68-
import org.springframework.data.redis.connection.RedisListCommands.*;
6968
import org.springframework.data.redis.core.Cursor;
7069
import org.springframework.data.redis.core.ScanOptions;
7170
import org.springframework.data.redis.core.script.DigestUtils;
@@ -2155,7 +2154,7 @@ public void zPopMinShouldWorkCorrectly() {
21552154
@EnabledOnCommand("BZPOPMIN")
21562155
public void bzPopMinShouldWorkCorrectly() {
21572156

2158-
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS))
2157+
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS))
21592158
.isNull();
21602159

21612160
nativeConnection.zadd(KEY_1_BYTES, 10D, VALUE_1_BYTES);
@@ -2183,7 +2182,7 @@ public void zPopMaxShouldWorkCorrectly() {
21832182
@EnabledOnCommand("BZPOPMAX")
21842183
public void bzPopMaxShouldWorkCorrectly() {
21852184

2186-
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 1, TimeUnit.MILLISECONDS))
2185+
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS))
21872186
.isNull();
21882187

21892188
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
@@ -91,13 +91,10 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
9191
private static final GeoLocation<String> PALERMO = new GeoLocation<>("palermo", POINT_PALERMO);
9292

9393
private static final GeoLocation<byte[]> ARIGENTO_BYTES = new GeoLocation<>(
94-
"arigento".getBytes(StandardCharsets.UTF_8),
95-
POINT_ARIGENTO);
96-
private static final GeoLocation<byte[]> CATANIA_BYTES = new GeoLocation<>(
97-
"catania".getBytes(StandardCharsets.UTF_8),
94+
"arigento".getBytes(StandardCharsets.UTF_8), POINT_ARIGENTO);
95+
private static final GeoLocation<byte[]> CATANIA_BYTES = new GeoLocation<>("catania".getBytes(StandardCharsets.UTF_8),
9896
POINT_CATANIA);
99-
private static final GeoLocation<byte[]> PALERMO_BYTES = new GeoLocation<>(
100-
"palermo".getBytes(StandardCharsets.UTF_8),
97+
private static final GeoLocation<byte[]> PALERMO_BYTES = new GeoLocation<>("palermo".getBytes(StandardCharsets.UTF_8),
10198
POINT_PALERMO);
10299

103100
private final RedisClusterClient client;
@@ -177,7 +174,6 @@ void shouldCreateClusterConnectionWithPooling() {
177174
factory.destroy();
178175
}
179176

180-
181177
@Test // DATAREDIS-315
182178
public void appendShouldAddValueCorrectly() {
183179

@@ -2193,6 +2189,8 @@ public void zPopMinShouldWorkCorrectly() {
21932189
@EnabledOnCommand("BZPOPMIN")
21942190
public void bzPopMinShouldWorkCorrectly() {
21952191

2192+
assertThat(clusterConnection.bZPopMin(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
2193+
21962194
nativeConnection.zadd(KEY_1, 10D, VALUE_1);
21972195
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
21982196
nativeConnection.zadd(KEY_1, 30D, VALUE_3);
@@ -2205,6 +2203,8 @@ public void bzPopMinShouldWorkCorrectly() {
22052203
@EnabledOnCommand("ZPOPMAX")
22062204
public void zPopMaxShouldWorkCorrectly() {
22072205

2206+
assertThat(clusterConnection.bZPopMax(KEY_1_BYTES, 10, TimeUnit.MILLISECONDS)).isNull();
2207+
22082208
nativeConnection.zadd(KEY_1, 10D, VALUE_1);
22092209
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
22102210
nativeConnection.zadd(KEY_1, 30D, VALUE_3);
@@ -2376,8 +2376,8 @@ public void zRangeWithScoresShouldReturnValuesAndScoreCorrectly() {
23762376
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
23772377
nativeConnection.zadd(KEY_1, 5D, VALUE_3);
23782378

2379-
assertThat(clusterConnection.zRangeWithScores(KEY_1_BYTES, 1, 2))
2380-
.contains(new DefaultTuple(VALUE_1_BYTES, 10D), new DefaultTuple(VALUE_2_BYTES, 20D));
2379+
assertThat(clusterConnection.zRangeWithScores(KEY_1_BYTES, 1, 2)).contains(new DefaultTuple(VALUE_1_BYTES, 10D),
2380+
new DefaultTuple(VALUE_2_BYTES, 20D));
23812381
}
23822382

23832383
@Test // DATAREDIS-315
@@ -2494,8 +2494,8 @@ public void zRevRangeWithScoresShouldReturnValuesAndScoreCorrectly() {
24942494
nativeConnection.zadd(KEY_1, 20D, VALUE_2);
24952495
nativeConnection.zadd(KEY_1, 5D, VALUE_3);
24962496

2497-
assertThat(clusterConnection.zRevRangeWithScores(KEY_1_BYTES, 1, 2))
2498-
.contains(new DefaultTuple(VALUE_3_BYTES, 5D), new DefaultTuple(VALUE_1_BYTES, 10D));
2497+
assertThat(clusterConnection.zRevRangeWithScores(KEY_1_BYTES, 1, 2)).contains(new DefaultTuple(VALUE_3_BYTES, 5D),
2498+
new DefaultTuple(VALUE_1_BYTES, 10D));
24992499
}
25002500

25012501
@Test

0 commit comments

Comments
 (0)