Skip to content

Commit 63e3bbc

Browse files
omg
1 parent 7997567 commit 63e3bbc

File tree

96 files changed

+1419
-1085
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1419
-1085
lines changed

src/main/java/org/springframework/data/redis/TooManyClusterRedirectionsException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.io.Serial;
1919

20+
import org.jspecify.annotations.Nullable;
2021
import org.springframework.dao.DataRetrievalFailureException;
2122

2223
/**
@@ -35,7 +36,7 @@ public class TooManyClusterRedirectionsException extends DataRetrievalFailureExc
3536
*
3637
* @param msg the detail message.
3738
*/
38-
public TooManyClusterRedirectionsException(String msg) {
39+
public TooManyClusterRedirectionsException(@Nullable String msg) {
3940
super(msg);
4041
}
4142

@@ -45,7 +46,7 @@ public TooManyClusterRedirectionsException(String msg) {
4546
* @param msg the detail message.
4647
* @param cause the root cause from the data access API in use.
4748
*/
48-
public TooManyClusterRedirectionsException(String msg, Throwable cause) {
49+
public TooManyClusterRedirectionsException(@Nullable String msg, @Nullable Throwable cause) {
4950
super(msg, cause);
5051
}
5152

src/main/java/org/springframework/data/redis/connection/BitFieldSubCommands.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Iterator;
2222
import java.util.List;
2323

24+
import org.jspecify.annotations.NullUnmarked;
2425
import org.jspecify.annotations.Nullable;
2526
import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldSubCommand;
2627
import org.springframework.util.Assert;
@@ -573,10 +574,11 @@ public String toString() {
573574
/**
574575
* @author Christoph Strobl
575576
*/
577+
@NullUnmarked
576578
public static abstract class AbstractBitFieldSubCommand implements BitFieldSubCommand {
577579

578-
BitFieldType type;
579-
Offset offset;
580+
BitFieldType type;
581+
Offset offset;
580582

581583
@Override
582584
public BitFieldType getType() {

src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@
1515
*/
1616
package org.springframework.data.redis.connection;
1717

18-
import java.util.*;
18+
import java.util.ArrayList;
19+
import java.util.Arrays;
20+
import java.util.Collection;
21+
import java.util.Collections;
22+
import java.util.Comparator;
23+
import java.util.HashMap;
24+
import java.util.Iterator;
25+
import java.util.LinkedHashMap;
26+
import java.util.List;
27+
import java.util.Map;
28+
import java.util.Objects;
29+
import java.util.Random;
30+
import java.util.TreeMap;
1931
import java.util.concurrent.Callable;
2032
import java.util.concurrent.ExecutionException;
2133
import java.util.concurrent.Future;
@@ -255,8 +267,7 @@ <T> MultiNodeResult<T> collectResults(Map<NodeExecution, Future<NodeResult<T>>>
255267
} catch (ExecutionException ex) {
256268
entryIterator.remove();
257269
exceptionCollector.addException(nodeExecution, ex.getCause());
258-
} catch (TimeoutException ignore) {
259-
} catch (InterruptedException ex) {
270+
} catch (TimeoutException ignore) {} catch (InterruptedException ex) {
260271
Thread.currentThread().interrupt();
261272
exceptionCollector.addException(nodeExecution, ex);
262273
break OUT;
@@ -413,7 +424,8 @@ RedisClusterNode getNode() {
413424
*
414425
* @since 2.0.3
415426
*/
416-
@Nullable PositionalKey getPositionalKey() {
427+
@Nullable
428+
PositionalKey getPositionalKey() {
417429
return this.positionalKey;
418430
}
419431

@@ -488,6 +500,19 @@ public byte[] getKey() {
488500
return this.value;
489501
}
490502

503+
/**
504+
* Get the actual value of the command execution or raise an error if {@literal null}.
505+
*
506+
* @return can be {@literal null}.
507+
* @throws IllegalArgumentException in case the value is {@literal null}.
508+
* @since 4.0
509+
*/
510+
public T getRequiredValue() {
511+
512+
Assert.notNull(this.value, "Expected non null value, but was null");
513+
return this.value;
514+
}
515+
491516
/**
492517
* Apply the {@link Function mapper function} to the value and return the mapped value.
493518
*

src/main/java/org/springframework/data/redis/connection/ReactiveGeoCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,8 @@ default Mono<Long> geoAdd(ByteBuffer key, Collection<GeoLocation<ByteBuffer>> lo
183183
*/
184184
class GeoDistCommand extends KeyCommand {
185185

186-
private final ByteBuffer from;
187-
private final ByteBuffer to;
186+
private final @Nullable ByteBuffer from;
187+
private final @Nullable ByteBuffer to;
188188
private final Metric metric;
189189

190190
private GeoDistCommand(@Nullable ByteBuffer key, @Nullable ByteBuffer from, @Nullable ByteBuffer to,

src/main/java/org/springframework/data/redis/connection/ReactiveHyperLogLogCommands.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.redis.connection;
1717

18+
import org.jspecify.annotations.Nullable;
1819
import reactor.core.publisher.Flux;
1920
import reactor.core.publisher.Mono;
2021

@@ -50,7 +51,7 @@ class PfAddCommand extends KeyCommand {
5051

5152
private final List<ByteBuffer> values;
5253

53-
private PfAddCommand(ByteBuffer key, List<ByteBuffer> values) {
54+
private PfAddCommand(@Nullable ByteBuffer key, List<ByteBuffer> values) {
5455

5556
super(key);
5657
this.values = values;
@@ -193,7 +194,7 @@ public List<ByteBuffer> getKeys() {
193194
}
194195

195196
@Override
196-
public ByteBuffer getKey() {
197+
public @Nullable ByteBuffer getKey() {
197198
return null;
198199
}
199200
}
@@ -245,7 +246,7 @@ class PfMergeCommand extends KeyCommand {
245246

246247
private final List<ByteBuffer> sourceKeys;
247248

248-
private PfMergeCommand(ByteBuffer key, List<ByteBuffer> sourceKeys) {
249+
private PfMergeCommand(@Nullable ByteBuffer key, List<ByteBuffer> sourceKeys) {
249250

250251
super(key);
251252
this.sourceKeys = sourceKeys;

src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,11 +710,11 @@ class ExpireAtCommand extends KeyCommand {
710710
private @Nullable Instant expireAt;
711711
private final ExpirationOptions options;
712712

713-
private ExpireAtCommand(ByteBuffer key, Instant expireAt) {
713+
private ExpireAtCommand(@Nullable ByteBuffer key, @Nullable Instant expireAt) {
714714
this(key, expireAt, ExpirationOptions.none());
715715
}
716716

717-
private ExpireAtCommand(@Nullable ByteBuffer key, Instant expireAt, ExpirationOptions options) {
717+
private ExpireAtCommand(@Nullable ByteBuffer key, @Nullable Instant expireAt, ExpirationOptions options) {
718718

719719
super(key);
720720

src/main/java/org/springframework/data/redis/connection/ReactiveListCommands.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ public BPopCommand blockingFor(Duration timeout) {
12771277
}
12781278

12791279
@Override
1280-
public ByteBuffer getKey() {
1280+
public @Nullable ByteBuffer getKey() {
12811281
return null;
12821282
}
12831283

@@ -1316,11 +1316,11 @@ public PopResult(List<ByteBuffer> result) {
13161316
this.result = result;
13171317
}
13181318

1319-
public ByteBuffer getKey() {
1319+
public @Nullable ByteBuffer getKey() {
13201320
return ObjectUtils.isEmpty(result) ? null : result.get(0);
13211321
}
13221322

1323-
public ByteBuffer getValue() {
1323+
public @Nullable ByteBuffer getValue() {
13241324
return ObjectUtils.isEmpty(result) ? null : result.get(1);
13251325
}
13261326

src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public KeyCommand(@Nullable ByteBuffer key) {
205205
}
206206

207207
@Override
208-
public ByteBuffer getKey() {
208+
public @Nullable ByteBuffer getKey() {
209209
return key;
210210
}
211211
}

src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ default Mono<RecordId> xAdd(ByteBufferRecord record) {
402402
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
403403
* @since 3.4
404404
*/
405+
@SuppressWarnings("nullAway")
405406
default Mono<RecordId> xAdd(ByteBufferRecord record, XAddOptions xAddOptions) {
406407

407408
Assert.notNull(record, "Record must not be null");

src/main/java/org/springframework/data/redis/connection/ReactiveStringCommands.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ public interface ReactiveStringCommands {
6161
class SetCommand extends KeyCommand {
6262

6363
private @Nullable ByteBuffer value;
64-
private Expiration expiration;
65-
private SetOption option;
64+
private @Nullable Expiration expiration;
65+
private @Nullable SetOption option;
6666

6767
private SetCommand(ByteBuffer key, @Nullable ByteBuffer value, @Nullable Expiration expiration,
6868
@Nullable SetOption option) {
@@ -859,7 +859,7 @@ class SetBitCommand extends KeyCommand {
859859
private @Nullable Long offset;
860860
private boolean value;
861861

862-
private SetBitCommand(ByteBuffer key, Long offset, boolean value) {
862+
private SetBitCommand(ByteBuffer key, @Nullable Long offset, boolean value) {
863863

864864
super(key);
865865

@@ -1078,7 +1078,7 @@ public BitFieldCommand commands(BitFieldSubCommands commands) {
10781078
return new BitFieldCommand(getKey(), commands);
10791079
}
10801080

1081-
public BitFieldSubCommands getSubCommands() {
1081+
public @Nullable BitFieldSubCommands getSubCommands() {
10821082
return subcommands;
10831083
}
10841084
}

src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ public boolean isReturnTotalChanged() {
264264
* @return
265265
* @see <a href="https://redis.io/commands/zadd">Redis Documentation: ZADD</a>
266266
*/
267+
@SuppressWarnings("nullAway")
267268
default Mono<Long> zAdd(ByteBuffer key, Double score, ByteBuffer value) {
268269

269270
Assert.notNull(key, "Key must not be null");
@@ -282,6 +283,7 @@ default Mono<Long> zAdd(ByteBuffer key, Double score, ByteBuffer value) {
282283
* @return
283284
* @see <a href="https://redis.io/commands/zadd">Redis Documentation: ZADD</a>
284285
*/
286+
@SuppressWarnings("nullAway")
285287
default Mono<Long> zAdd(ByteBuffer key, Collection<? extends Tuple> tuples) {
286288

287289
Assert.notNull(key, "Key must not be null");
@@ -941,7 +943,7 @@ default Flux<Tuple> zRevRangeWithScores(ByteBuffer key, Range<Long> range) {
941943
*/
942944
class ZRangeStoreCommand extends KeyCommand {
943945

944-
private final ByteBuffer destKey;
946+
private final @Nullable ByteBuffer destKey;
945947
private final RangeMode rangeMode;
946948
private final Range<?> range;
947949
private final Direction direction;
@@ -2158,7 +2160,7 @@ class ZRemRangeByRankCommand extends KeyCommand {
21582160

21592161
private final Range<Long> range;
21602162

2161-
private ZRemRangeByRankCommand(ByteBuffer key, Range<Long> range) {
2163+
private ZRemRangeByRankCommand(@Nullable ByteBuffer key, Range<Long> range) {
21622164
super(key);
21632165
this.range = range;
21642166
}
@@ -2860,7 +2862,7 @@ Flux<CommandResponse<ZAggregateCommand, Flux<Tuple>>> zInterWithScores(
28602862
*/
28612863
class ZInterStoreCommand extends ZAggregateStoreCommand {
28622864

2863-
private ZInterStoreCommand(ByteBuffer key, List<ByteBuffer> sourceKeys, List<Double> weights,
2865+
private ZInterStoreCommand(@Nullable ByteBuffer key, List<ByteBuffer> sourceKeys, List<Double> weights,
28642866
@Nullable Aggregate aggregate) {
28652867
super(key, sourceKeys, weights, aggregate);
28662868
}

src/main/java/org/springframework/data/redis/connection/RedisClusterCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public interface RedisClusterCommands {
127127
* @param slots
128128
* @see <a href="https://redis.io/commands/cluster-delslots">Redis Documentation: CLUSTER DELSLOTS</a>
129129
*/
130-
void clusterDeleteSlots(RedisClusterNode node, int... slots);
130+
void clusterDeleteSlots( @NonNull RedisClusterNode node, int @NonNull ... slots);
131131

132132
/**
133133
* Removes {@link SlotRange#getSlotsArray()} from given {@link RedisClusterNode}.

src/main/java/org/springframework/data/redis/connection/RedisKeyCommands.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ default Boolean exists(byte @NonNull [] key) {
141141
/**
142142
* Use a {@link Cursor} to iterate over keys.
143143
*
144-
* @param options must not be {@literal null}.
144+
* @param options can be {@literal null}.
145145
* @return never {@literal null}.
146146
* @since 1.4
147147
* @see <a href="https://redis.io/commands/scan">Redis Documentation: SCAN</a>
148148
*/
149-
Cursor<byte @NonNull []> scan(@NonNull ScanOptions options);
149+
Cursor<byte @NonNull []> scan(@Nullable ScanOptions options);
150150

151151
/**
152152
* Return a random key from the keyspace.

src/main/java/org/springframework/data/redis/connection/RedisNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public String asString() {
225225
return this.name;
226226
}
227227

228-
public void setName(String name) {
228+
public void setName(@Nullable String name) {
229229
this.name = name;
230230
}
231231

0 commit comments

Comments
 (0)