Skip to content

Commit 06eecce

Browse files
tmp save
1 parent 467dab1 commit 06eecce

Some content is hidden

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

43 files changed

+966
-1085
lines changed

src/main/java/org/springframework/data/redis/cache/RedisCache.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
@SuppressWarnings("unused")
5858
public class RedisCache extends AbstractValueAdaptingCache {
5959

60+
@SuppressWarnings("NullAway")
6061
static final byte[] BINARY_NULL_VALUE = RedisSerializer.java().serialize(NullValue.INSTANCE);
6162

6263
static final String CACHE_RETRIEVAL_UNSUPPORTED_OPERATION_EXCEPTION_MESSAGE = "The Redis driver configured with RedisCache through RedisCacheWriter does not support CompletableFuture-based retrieval";
@@ -146,7 +147,7 @@ public CacheStatistics getStatistics() {
146147

147148
@Override
148149
@SuppressWarnings("unchecked")
149-
public <T> T get(Object key, Callable<T> valueLoader) {
150+
public <T> @Nullable T get(Object key, Callable<T> valueLoader) {
150151

151152
byte[] binaryKey = createAndConvertCacheKey(key);
152153
byte[] binaryValue = getCacheWriter().get(getName(), binaryKey,
@@ -176,7 +177,7 @@ protected <T> T loadCacheValue(Object key, Callable<T> valueLoader) {
176177
}
177178

178179
@Override
179-
protected Object lookup(Object key) {
180+
protected @Nullable Object lookup(Object key) {
180181

181182
byte[] binaryKey = createAndConvertCacheKey(key);
182183

@@ -209,7 +210,7 @@ public void put(Object key, @Nullable Object value) {
209210
}
210211

211212
@Override
212-
public ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
213+
public @Nullable ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
213214

214215
Object cacheValue = preProcessCacheValue(value);
215216

@@ -291,7 +292,7 @@ public <T> CompletableFuture<T> retrieve(Object key, Supplier<CompletableFuture<
291292
});
292293
}
293294

294-
private Object processAndCheckValue(@Nullable Object value) {
295+
private @Nullable Object processAndCheckValue(@Nullable Object value) {
295296

296297
Object cacheValue = preProcessCacheValue(value);
297298

@@ -379,6 +380,7 @@ protected String createCacheKey(Object key) {
379380
* @return never {@literal null}.
380381
* @throws IllegalStateException if {@code key} cannot be converted to {@link String}.
381382
*/
383+
@SuppressWarnings("NullAway")
382384
protected String convertKey(Object key) {
383385

384386
if (key instanceof String stringKey) {

src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ protected RedisCacheWriter getCacheWriter() {
374374
}
375375

376376
@Override
377-
protected RedisCache getMissingCache(String name) {
377+
protected @Nullable RedisCache getMissingCache(String name) {
378378
return isAllowRuntimeCacheCreation() ? createRedisCache(name, getDefaultCacheConfiguration()) : null;
379379
}
380380

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ RedisClusterNode getNode() {
412412
*
413413
* @since 2.0.3
414414
*/
415-
PositionalKey getPositionalKey() {
415+
@Nullable PositionalKey getPositionalKey() {
416416
return this.positionalKey;
417417
}
418418

@@ -801,7 +801,7 @@ public Iterator<PositionalKey> iterator() {
801801
*/
802802
private class NodeExceptionCollector {
803803

804-
private final Map<RedisClusterNode, Throwable> exceptions = new HashMap<>();
804+
private final Map<RedisClusterNode, @Nullable Throwable> exceptions = new HashMap<>();
805805

806806
/**
807807
* @return {@code true} if the collector contains at least one exception.
@@ -810,7 +810,7 @@ public boolean hasExceptions() {
810810
return !exceptions.isEmpty();
811811
}
812812

813-
public void addException(NodeExecution execution, Throwable throwable) {
813+
public void addException(NodeExecution execution, @Nullable Throwable throwable) {
814814

815815
Throwable translated = throwable instanceof Exception e ? convertToDataAccessException(e) : throwable;
816816
Throwable resolvedException = translated != null ? translated : throwable;
@@ -821,7 +821,7 @@ public void addException(NodeExecution execution, Throwable throwable) {
821821
/**
822822
* @return the collected exceptions.
823823
*/
824-
public List<? extends Throwable> getExceptions() {
824+
public List<? extends @Nullable Throwable> getExceptions() {
825825
return new ArrayList<>(exceptions.values());
826826
}
827827
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ public RedisClusterNode lookup(String nodeId) {
193193
* @return never {@literal null}.
194194
* @throws ClusterStateFailureException
195195
*/
196+
@SuppressWarnings("NullAway")
196197
public RedisClusterNode lookup(RedisClusterNode node) {
197198

198199
Assert.notNull(node, "RedisClusterNode must not be null");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void setByPattern(byte[] byPattern) {
8080
this.byPattern = byPattern;
8181
}
8282

83-
public Range getLimit() {
83+
public @Nullable Range getLimit() {
8484
return limit;
8585
}
8686

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import java.util.List;
2020
import java.util.Map;
2121

22+
import org.jspecify.annotations.NonNull;
23+
import org.jspecify.annotations.NullUnmarked;
2224
import org.springframework.data.redis.connection.RedisClusterNode.SlotRange;
2325

2426
/**
@@ -30,6 +32,7 @@
3032
* @author Mark Paluch
3133
* @since 1.7
3234
*/
35+
@NullUnmarked
3336
public interface RedisClusterCommands {
3437

3538
/**
@@ -38,7 +41,7 @@ public interface RedisClusterCommands {
3841
* @return never {@literal null}.
3942
* @see <a href="https://redis.io/commands/cluster-nodes">Redis Documentation: CLUSTER NODES</a>
4043
*/
41-
Iterable<RedisClusterNode> clusterGetNodes();
44+
Iterable<@NonNull RedisClusterNode> clusterGetNodes();
4245

4346
/**
4447
* Retrieve information about connected replicas for given master node.
@@ -47,15 +50,15 @@ public interface RedisClusterCommands {
4750
* @return never {@literal null}.
4851
* @see <a href="https://redis.io/commands/cluster-replicas">Redis Documentation: CLUSTER REPLICAS</a>
4952
*/
50-
Collection<RedisClusterNode> clusterGetReplicas(RedisClusterNode master);
53+
Collection<@NonNull RedisClusterNode> clusterGetReplicas(@NonNull RedisClusterNode master);
5154

5255
/**
5356
* Retrieve information about masters and their connected replicas.
5457
*
5558
* @return never {@literal null}.
5659
* @see <a href="https://redis.io/commands/cluster-replicas">Redis Documentation: CLUSTER REPLICAS</a>
5760
*/
58-
Map<RedisClusterNode, Collection<RedisClusterNode>> clusterGetMasterReplicaMap();
61+
Map<@NonNull RedisClusterNode, @NonNull Collection<@NonNull RedisClusterNode>> clusterGetMasterReplicaMap();
5962

6063
/**
6164
* Find the slot for a given {@code key}.
@@ -64,7 +67,7 @@ public interface RedisClusterCommands {
6467
* @return
6568
* @see <a href="https://redis.io/commands/cluster-keyslot">Redis Documentation: CLUSTER KEYSLOT</a>
6669
*/
67-
Integer clusterGetSlotForKey(byte[] key);
70+
Integer clusterGetSlotForKey(byte @NonNull [] key);
6871

6972
/**
7073
* Find the {@link RedisClusterNode} serving given {@literal slot}.
@@ -80,7 +83,7 @@ public interface RedisClusterCommands {
8083
* @param key must not be {@literal null}.
8184
* @return
8285
*/
83-
RedisClusterNode clusterGetNodeForKey(byte[] key);
86+
RedisClusterNode clusterGetNodeForKey(byte @NonNull [] key);
8487

8588
/**
8689
* Get cluster information.
@@ -97,7 +100,7 @@ public interface RedisClusterCommands {
97100
* @param slots
98101
* @see <a href="https://redis.io/commands/cluster-addslots">Redis Documentation: CLUSTER ADDSLOTS</a>
99102
*/
100-
void clusterAddSlots(RedisClusterNode node, int... slots);
103+
void clusterAddSlots(@NonNull RedisClusterNode node, int @NonNull... slots);
101104

102105
/**
103106
* Assign {@link SlotRange#getSlotsArray()} to given {@link RedisClusterNode}.
@@ -106,7 +109,7 @@ public interface RedisClusterCommands {
106109
* @param range must not be {@literal null}.
107110
* @see <a href="https://redis.io/commands/cluster-addslots">Redis Documentation: CLUSTER ADDSLOTS</a>
108111
*/
109-
void clusterAddSlots(RedisClusterNode node, SlotRange range);
112+
void clusterAddSlots(@NonNull RedisClusterNode node, @NonNull SlotRange range);
110113

111114
/**
112115
* Count the number of keys assigned to one {@literal slot}.
@@ -133,15 +136,15 @@ public interface RedisClusterCommands {
133136
* @param range must not be {@literal null}.
134137
* @see <a href="https://redis.io/commands/cluster-delslots">Redis Documentation: CLUSTER DELSLOTS</a>
135138
*/
136-
void clusterDeleteSlotsInRange(RedisClusterNode node, SlotRange range);
139+
void clusterDeleteSlotsInRange(@NonNull RedisClusterNode node, @NonNull SlotRange range);
137140

138141
/**
139142
* Remove given {@literal node} from cluster.
140143
*
141144
* @param node must not be {@literal null}.
142145
* @see <a href="https://redis.io/commands/cluster-forget">Redis Documentation: CLUSTER FORGET</a>
143146
*/
144-
void clusterForget(RedisClusterNode node);
147+
void clusterForget(@NonNull RedisClusterNode node);
145148

146149
/**
147150
* Add given {@literal node} to cluster.
@@ -150,15 +153,15 @@ public interface RedisClusterCommands {
150153
* not be {@literal null}.
151154
* @see <a href="https://redis.io/commands/cluster-meet">Redis Documentation: CLUSTER MEET</a>
152155
*/
153-
void clusterMeet(RedisClusterNode node);
156+
void clusterMeet(@NonNull RedisClusterNode node);
154157

155158
/**
156159
* @param node must not be {@literal null}.
157160
* @param slot
158161
* @param mode must not be{@literal null}.
159162
* @see <a href="https://redis.io/commands/cluster-setslot">Redis Documentation: CLUSTER SETSLOT</a>
160163
*/
161-
void clusterSetSlot(RedisClusterNode node, int slot, AddSlots mode);
164+
void clusterSetSlot(@NonNull RedisClusterNode node, int slot, @NonNull AddSlots mode);
162165

163166
/**
164167
* Get {@literal keys} served by slot.
@@ -168,7 +171,7 @@ public interface RedisClusterCommands {
168171
* @return
169172
* @see <a href="https://redis.io/commands/cluster-getkeysinslot">Redis Documentation: CLUSTER GETKEYSINSLOT</a>
170173
*/
171-
List<byte[]> clusterGetKeysInSlot(int slot, Integer count);
174+
List<byte[]> clusterGetKeysInSlot(int slot, @NonNull Integer count);
172175

173176
/**
174177
* Assign a {@literal replica} to given {@literal master}.
@@ -177,7 +180,7 @@ public interface RedisClusterCommands {
177180
* @param replica must not be {@literal null}.
178181
* @see <a href="https://redis.io/commands/cluster-replicate">Redis Documentation: CLUSTER REPLICATE</a>
179182
*/
180-
void clusterReplicate(RedisClusterNode master, RedisClusterNode replica);
183+
void clusterReplicate(@NonNull RedisClusterNode master, @NonNull RedisClusterNode replica);
181184

182185
enum AddSlots {
183186
MIGRATING, IMPORTING, STABLE, NODE

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import java.util.Collection;
1919
import java.util.Set;
2020

21-
import org.jspecify.annotations.Nullable;
21+
import org.jspecify.annotations.NonNull;
22+
import org.jspecify.annotations.NullUnmarked;
2223
import org.springframework.data.redis.core.Cursor;
2324
import org.springframework.data.redis.core.ScanOptions;
2425
import org.springframework.util.Assert;
@@ -36,6 +37,7 @@
3637
* @author Mark Paluch
3738
* @since 1.7
3839
*/
40+
@NullUnmarked
3941
public interface RedisClusterConnection
4042
extends RedisConnection, DefaultedRedisClusterConnection, RedisClusterCommandsProvider {
4143

@@ -44,17 +46,15 @@ public interface RedisClusterConnection
4446
* @return {@literal null} when used in pipeline / transaction.
4547
* @see RedisConnectionCommands#ping()
4648
*/
47-
@Nullable
48-
String ping(RedisClusterNode node);
49+
String ping(@NonNull RedisClusterNode node);
4950

5051
/**
5152
* @param node must not be {@literal null}.
5253
* @param pattern must not be {@literal null}.
5354
* @return {@literal null} when used in pipeline / transaction.
5455
* @see RedisKeyCommands#keys(byte[])
5556
*/
56-
@Nullable
57-
Set<byte[]> keys(RedisClusterNode node, byte[] pattern);
57+
Set<byte @NonNull []> keys(@NonNull RedisClusterNode node, byte @NonNull [] pattern);
5858

5959
/**
6060
* Use a {@link Cursor} to iterate over keys.
@@ -65,14 +65,14 @@ public interface RedisClusterConnection
6565
* @since 2.1
6666
* @see <a href="https://redis.io/commands/scan">Redis Documentation: SCAN</a>
6767
*/
68-
Cursor<byte[]> scan(RedisClusterNode node, ScanOptions options);
68+
Cursor<byte @NonNull []> scan(@NonNull RedisClusterNode node, @NonNull ScanOptions options);
6969

7070
/**
7171
* @param node must not be {@literal null}.
7272
* @return {@literal null} when no keys stored at node or when used in pipeline / transaction.
7373
* @see RedisKeyCommands#randomKey()
7474
*/
75-
byte @Nullable[] randomKey(RedisClusterNode node);
75+
byte[] randomKey(@NonNull RedisClusterNode node);
7676

7777
/**
7878
* Execute the given command for the {@code key} provided potentially appending args. <br />
@@ -92,7 +92,7 @@ public interface RedisClusterConnection
9292
* @return command result as delivered by the underlying Redis driver. Can be {@literal null}.
9393
* @since 2.1
9494
*/
95-
default <T> @Nullable T execute(String command, byte[] key, Collection<byte[]> args) {
95+
default <T> T execute(@NonNull String command, byte @NonNull [] key, @NonNull Collection<byte @NonNull []> args) {
9696

9797
Assert.notNull(command, "Command must not be null");
9898
Assert.notNull(key, "Key must not be null");

0 commit comments

Comments
 (0)