diff --git a/pom.xml b/pom.xml
index b780d1e99c..c2f383da90 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.springframework.data
spring-data-redis
- 4.0.0-SNAPSHOT
+ 4.0.0-GH-3290-SNAPSHOT
Spring Data Redis
Spring Data module for Redis
diff --git a/src/main/java/org/springframework/data/redis/ClusterRedirectException.java b/src/main/java/org/springframework/data/redis/ClusterRedirectException.java
index 562347e86a..2c50c5ca57 100644
--- a/src/main/java/org/springframework/data/redis/ClusterRedirectException.java
+++ b/src/main/java/org/springframework/data/redis/ClusterRedirectException.java
@@ -17,6 +17,7 @@
import java.io.Serial;
+import org.jspecify.annotations.Nullable;
import org.springframework.dao.DataRetrievalFailureException;
/**
@@ -44,7 +45,7 @@ public class ClusterRedirectException extends DataRetrievalFailureException {
* @param targetPort the port on the host.
* @param e the root cause from the data access API in use.
*/
- public ClusterRedirectException(int slot, String targetHost, int targetPort, Throwable e) {
+ public ClusterRedirectException(int slot, String targetHost, int targetPort, @Nullable Throwable e) {
super("Redirect: slot %s to %s:%s.".formatted(slot, targetHost, targetPort), e);
diff --git a/src/main/java/org/springframework/data/redis/ClusterStateFailureException.java b/src/main/java/org/springframework/data/redis/ClusterStateFailureException.java
index 29543870d6..8b354161aa 100644
--- a/src/main/java/org/springframework/data/redis/ClusterStateFailureException.java
+++ b/src/main/java/org/springframework/data/redis/ClusterStateFailureException.java
@@ -17,6 +17,7 @@
import java.io.Serial;
+import org.jspecify.annotations.Nullable;
import org.springframework.dao.DataAccessResourceFailureException;
/**
@@ -38,7 +39,7 @@ public class ClusterStateFailureException extends DataAccessResourceFailureExcep
*
* @param msg the detail message.
*/
- public ClusterStateFailureException(String msg) {
+ public ClusterStateFailureException(@Nullable String msg) {
super(msg);
}
@@ -48,7 +49,7 @@ public ClusterStateFailureException(String msg) {
* @param msg the detail message.
* @param cause the nested exception.
*/
- public ClusterStateFailureException(String msg, Throwable cause) {
+ public ClusterStateFailureException(@Nullable String msg, @Nullable Throwable cause) {
super(msg, cause);
}
diff --git a/src/main/java/org/springframework/data/redis/ExceptionTranslationStrategy.java b/src/main/java/org/springframework/data/redis/ExceptionTranslationStrategy.java
index a389a4c814..c255c30392 100644
--- a/src/main/java/org/springframework/data/redis/ExceptionTranslationStrategy.java
+++ b/src/main/java/org/springframework/data/redis/ExceptionTranslationStrategy.java
@@ -15,8 +15,8 @@
*/
package org.springframework.data.redis;
+import org.jspecify.annotations.Nullable;
import org.springframework.dao.DataAccessException;
-import org.springframework.lang.Nullable;
/**
* Potentially translates an {@link Exception} into appropriate {@link DataAccessException}.
diff --git a/src/main/java/org/springframework/data/redis/PassThroughExceptionTranslationStrategy.java b/src/main/java/org/springframework/data/redis/PassThroughExceptionTranslationStrategy.java
index 55da37766b..f8649f6e69 100644
--- a/src/main/java/org/springframework/data/redis/PassThroughExceptionTranslationStrategy.java
+++ b/src/main/java/org/springframework/data/redis/PassThroughExceptionTranslationStrategy.java
@@ -15,9 +15,9 @@
*/
package org.springframework.data.redis;
+import org.jspecify.annotations.Nullable;
import org.springframework.core.convert.converter.Converter;
import org.springframework.dao.DataAccessException;
-import org.springframework.lang.Nullable;
/**
* {@link PassThroughExceptionTranslationStrategy} returns {@literal null} for unknown {@link Exception}s.
@@ -34,9 +34,8 @@ public PassThroughExceptionTranslationStrategy(Converter doGet(connection, name, key, ttl));
}
- @Nullable
- private byte[] doGet(RedisConnection connection, String name, byte[] key, @Nullable Duration ttl) {
+
+ @SuppressWarnings("NullAway")
+ private byte @Nullable[] doGet(RedisConnection connection, String name, byte[] key, @Nullable Duration ttl) {
byte[] result = shouldExpireWithin(ttl) ? connection.stringCommands().getEx(key, Expiration.from(ttl))
: connection.stringCommands().get(key);
@@ -241,6 +242,7 @@ public void put(String name, byte[] key, byte[] value, @Nullable Duration ttl) {
}
+ @SuppressWarnings("NullAway")
private void doPut(RedisConnection connection, String name, byte[] key, byte[] value, @Nullable Duration ttl) {
if (shouldExpireWithin(ttl)) {
@@ -265,6 +267,7 @@ public CompletableFuture store(String name, byte[] key, byte[] value, @Nul
}
@Override
+ @SuppressWarnings("NullAway")
public byte[] putIfAbsent(String name, byte[] key, byte[] value, @Nullable Duration ttl) {
Assert.notNull(name, "Name must not be null");
@@ -538,6 +541,7 @@ public boolean isSupported() {
}
@Override
+ @SuppressWarnings("NullAway")
public CompletableFuture retrieve(String name, byte[] key, @Nullable Duration ttl) {
return doWithConnection(connection -> {
@@ -572,6 +576,7 @@ private Mono doStoreWithLocking(String name, byte[] key, byte[] value,
unused -> doUnlock(name, connection));
}
+ @SuppressWarnings("NullAway")
private Mono doStore(byte[] cacheKey, byte[] value, @Nullable Duration ttl,
ReactiveRedisConnection connection) {
diff --git a/src/main/java/org/springframework/data/redis/cache/FixedDurationTtlFunction.java b/src/main/java/org/springframework/data/redis/cache/FixedDurationTtlFunction.java
index 6c456de4c8..d20c4a419d 100644
--- a/src/main/java/org/springframework/data/redis/cache/FixedDurationTtlFunction.java
+++ b/src/main/java/org/springframework/data/redis/cache/FixedDurationTtlFunction.java
@@ -17,8 +17,8 @@
import java.time.Duration;
+import org.jspecify.annotations.Nullable;
import org.springframework.data.redis.cache.RedisCacheWriter.TtlFunction;
-import org.springframework.lang.Nullable;
/**
* {@link TtlFunction} implementation returning the given, predetermined {@link Duration} used for per cache entry
diff --git a/src/main/java/org/springframework/data/redis/cache/NoOpCacheStatisticsCollector.java b/src/main/java/org/springframework/data/redis/cache/NoOpCacheStatisticsCollector.java
index 4180ce875d..b76be1cc15 100644
--- a/src/main/java/org/springframework/data/redis/cache/NoOpCacheStatisticsCollector.java
+++ b/src/main/java/org/springframework/data/redis/cache/NoOpCacheStatisticsCollector.java
@@ -18,7 +18,7 @@
import java.time.Instant;
import java.util.concurrent.TimeUnit;
-import org.springframework.lang.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.util.ObjectUtils;
/**
diff --git a/src/main/java/org/springframework/data/redis/cache/RedisCache.java b/src/main/java/org/springframework/data/redis/cache/RedisCache.java
index 8bf70e0853..5f3e5e7f86 100644
--- a/src/main/java/org/springframework/data/redis/cache/RedisCache.java
+++ b/src/main/java/org/springframework/data/redis/cache/RedisCache.java
@@ -27,6 +27,7 @@
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
+import org.jspecify.annotations.Nullable;
import org.springframework.cache.Cache;
import org.springframework.cache.support.AbstractValueAdaptingCache;
import org.springframework.cache.support.NullValue;
@@ -37,7 +38,6 @@
import org.springframework.data.redis.serializer.RedisSerializationContext;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.util.ByteUtils;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.ReflectionUtils;
@@ -57,6 +57,7 @@
@SuppressWarnings("unused")
public class RedisCache extends AbstractValueAdaptingCache {
+ @SuppressWarnings("NullAway")
static final byte[] BINARY_NULL_VALUE = RedisSerializer.java().serialize(NullValue.INSTANCE);
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() {
@Override
@SuppressWarnings("unchecked")
- public T get(Object key, Callable valueLoader) {
+ public @Nullable T get(Object key, Callable valueLoader) {
byte[] binaryKey = createAndConvertCacheKey(key);
byte[] binaryValue = getCacheWriter().get(getName(), binaryKey,
@@ -176,7 +177,7 @@ protected T loadCacheValue(Object key, Callable valueLoader) {
}
@Override
- protected Object lookup(Object key) {
+ protected @Nullable Object lookup(Object key) {
byte[] binaryKey = createAndConvertCacheKey(key);
@@ -196,6 +197,7 @@ private Duration getTimeToLive(Object key, @Nullable Object value) {
}
@Override
+ @SuppressWarnings("NullAway")
public void put(Object key, @Nullable Object value) {
Object cacheValue = processAndCheckValue(value);
@@ -209,7 +211,8 @@ public void put(Object key, @Nullable Object value) {
}
@Override
- public ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
+ @SuppressWarnings("NullAway")
+ public @Nullable ValueWrapper putIfAbsent(Object key, @Nullable Object value) {
Object cacheValue = preProcessCacheValue(value);
@@ -268,7 +271,7 @@ public CompletableFuture retrieve(Object key) {
}
@Override
- @SuppressWarnings("unchecked")
+ @SuppressWarnings({"unchecked", "NullAway"})
public CompletableFuture retrieve(Object key, Supplier> valueLoader) {
return retrieve(key).thenCompose(wrapper -> {
@@ -291,7 +294,7 @@ public CompletableFuture retrieve(Object key, Supplier retrieveValue(Object key) {
.thenApply(this::toValueWrapper);
}
- @Nullable
- private Object nullSafeDeserializedStoreValue(@Nullable byte[] value) {
+ private @Nullable Object nullSafeDeserializedStoreValue(byte @Nullable[] value) {
return value != null ? fromStoreValue(deserializeCacheValue(value)) : null;
}
diff --git a/src/main/java/org/springframework/data/redis/cache/RedisCacheConfiguration.java b/src/main/java/org/springframework/data/redis/cache/RedisCacheConfiguration.java
index b74ebf2d75..bb774e4fd3 100644
--- a/src/main/java/org/springframework/data/redis/cache/RedisCacheConfiguration.java
+++ b/src/main/java/org/springframework/data/redis/cache/RedisCacheConfiguration.java
@@ -19,6 +19,7 @@
import java.time.Duration;
import java.util.function.Consumer;
+import org.jspecify.annotations.Nullable;
import org.springframework.cache.Cache;
import org.springframework.cache.interceptor.SimpleKey;
import org.springframework.core.convert.ConversionService;
@@ -28,7 +29,6 @@
import org.springframework.data.redis.serializer.RedisSerializationContext.SerializationPair;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.format.support.DefaultFormattingConversionService;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
diff --git a/src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java b/src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java
index 3c9e3c5415..4e65c67b1c 100644
--- a/src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java
+++ b/src/main/java/org/springframework/data/redis/cache/RedisCacheManager.java
@@ -23,11 +23,11 @@
import java.util.Optional;
import java.util.Set;
+import org.jspecify.annotations.Nullable;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.transaction.AbstractTransactionSupportingCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -374,7 +374,7 @@ protected RedisCacheWriter getCacheWriter() {
}
@Override
- protected RedisCache getMissingCache(String name) {
+ protected @Nullable RedisCache getMissingCache(String name) {
return isAllowRuntimeCacheCreation() ? createRedisCache(name, getDefaultCacheConfiguration()) : null;
}
diff --git a/src/main/java/org/springframework/data/redis/cache/RedisCacheWriter.java b/src/main/java/org/springframework/data/redis/cache/RedisCacheWriter.java
index e5e3d16b2b..25ec4f0388 100644
--- a/src/main/java/org/springframework/data/redis/cache/RedisCacheWriter.java
+++ b/src/main/java/org/springframework/data/redis/cache/RedisCacheWriter.java
@@ -19,8 +19,8 @@
import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;
+import org.jspecify.annotations.Nullable;
import org.springframework.data.redis.connection.RedisConnectionFactory;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -119,8 +119,8 @@ static RedisCacheWriter lockingRedisCacheWriter(RedisConnectionFactory connectio
* @return {@literal null} if key does not exist.
* @see #get(String, byte[], Duration)
*/
- @Nullable
- byte[] get(String name, byte[] key);
+ byte @Nullable[] get(String name, byte[] key);
+
/**
* Get the binary value representation from Redis stored for the given key and set the given {@link Duration TTL
@@ -131,8 +131,7 @@ static RedisCacheWriter lockingRedisCacheWriter(RedisConnectionFactory connectio
* @param ttl {@link Duration} specifying the {@literal expiration timeout} for the cache entry.
* @return {@literal null} if key does not exist or has {@literal expired}.
*/
- @Nullable
- default byte[] get(String name, byte[] key, @Nullable Duration ttl) {
+ default byte @Nullable[] get(String name, byte[] key, @Nullable Duration ttl) {
return get(name, key);
}
@@ -242,8 +241,7 @@ default CompletableFuture retrieve(String name, byte[] key) {
* @param ttl optional expiration time. Can be {@literal null}.
* @return {@literal null} if the value has been written, the value stored for the key if it already exists.
*/
- @Nullable
- byte[] putIfAbsent(String name, byte[] key, byte[] value, @Nullable Duration ttl);
+ byte @Nullable[] putIfAbsent(String name, byte[] key, byte[] value, @Nullable Duration ttl);
/**
* Remove the given key from Redis.
diff --git a/src/main/java/org/springframework/data/redis/cache/package-info.java b/src/main/java/org/springframework/data/redis/cache/package-info.java
index 3b4695da6c..00516a9bb2 100644
--- a/src/main/java/org/springframework/data/redis/cache/package-info.java
+++ b/src/main/java/org/springframework/data/redis/cache/package-info.java
@@ -3,6 +3,5 @@
* cache
* abstraction.
*/
-@org.springframework.lang.NonNullApi
-@org.springframework.lang.NonNullFields
+@org.jspecify.annotations.NullMarked
package org.springframework.data.redis.cache;
diff --git a/src/main/java/org/springframework/data/redis/config/package-info.java b/src/main/java/org/springframework/data/redis/config/package-info.java
index 41ea5708bd..37bcac4eac 100644
--- a/src/main/java/org/springframework/data/redis/config/package-info.java
+++ b/src/main/java/org/springframework/data/redis/config/package-info.java
@@ -1,6 +1,5 @@
/**
* Namespace and configuration.
*/
-@org.springframework.lang.NonNullApi
-@org.springframework.lang.NonNullFields
+@org.jspecify.annotations.NullMarked
package org.springframework.data.redis.config;
diff --git a/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java
index 46a7a12ded..421e356678 100644
--- a/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/AbstractRedisConnection.java
@@ -21,11 +21,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
+import org.jspecify.annotations.Nullable;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.dao.InvalidDataAccessResourceUsageException;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -64,6 +63,7 @@ public boolean hasRedisSentinelConfigured() {
return this.sentinelConfiguration != null;
}
+ @SuppressWarnings("NullAway")
private RedisNode selectActiveSentinel() {
Assert.state(hasRedisSentinelConfigured(), "Sentinel configuration missing");
diff --git a/src/main/java/org/springframework/data/redis/connection/BitFieldSubCommands.java b/src/main/java/org/springframework/data/redis/connection/BitFieldSubCommands.java
index b90121f90b..3be6e6cddb 100644
--- a/src/main/java/org/springframework/data/redis/connection/BitFieldSubCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/BitFieldSubCommands.java
@@ -21,8 +21,9 @@
import java.util.Iterator;
import java.util.List;
+import org.jspecify.annotations.NullUnmarked;
+import org.jspecify.annotations.Nullable;
import org.springframework.data.redis.connection.BitFieldSubCommands.BitFieldSubCommand;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -573,10 +574,11 @@ public String toString() {
/**
* @author Christoph Strobl
*/
+ @NullUnmarked
public static abstract class AbstractBitFieldSubCommand implements BitFieldSubCommand {
- BitFieldType type;
- Offset offset;
+ BitFieldType type;
+ Offset offset;
@Override
public BitFieldType getType() {
@@ -809,8 +811,7 @@ public long getValue() {
*
* @return can be {@literal null}.
*/
- @Nullable
- public Overflow getOverflow() {
+ public @Nullable Overflow getOverflow() {
return overflow;
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java
index b0d9c1a720..944177d28c 100644
--- a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java
+++ b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java
@@ -15,7 +15,19 @@
*/
package org.springframework.data.redis.connection;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Random;
+import java.util.TreeMap;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
@@ -24,6 +36,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;
+import org.jspecify.annotations.Nullable;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
@@ -34,7 +47,7 @@
import org.springframework.data.redis.TooManyClusterRedirectionsException;
import org.springframework.data.redis.connection.util.ByteArraySet;
import org.springframework.data.redis.connection.util.ByteArrayWrapper;
-import org.springframework.lang.Nullable;
+import org.springframework.lang.Contract;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
@@ -226,6 +239,7 @@ public MultiNodeResult executeCommandAsyncOnNodes(ClusterCommandCallba
return collectResults(futures);
}
+ @SuppressWarnings("NullAway")
MultiNodeResult collectResults(Map>> futures) {
MultiNodeResult result = new MultiNodeResult<>();
@@ -254,8 +268,7 @@ MultiNodeResult collectResults(Map>>
} catch (ExecutionException ex) {
entryIterator.remove();
exceptionCollector.addException(nodeExecution, ex.getCause());
- } catch (TimeoutException ignore) {
- } catch (InterruptedException ex) {
+ } catch (TimeoutException ignore) {} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
exceptionCollector.addException(nodeExecution, ex);
break OUT;
@@ -332,8 +345,7 @@ private ClusterTopology getClusterTopology() {
return this.topologyProvider.getTopology();
}
- @Nullable
- private DataAccessException convertToDataAccessException(Exception cause) {
+ private @Nullable DataAccessException convertToDataAccessException(Exception cause) {
return this.exceptionTranslationStrategy.translate(cause);
}
@@ -413,6 +425,7 @@ RedisClusterNode getNode() {
*
* @since 2.0.3
*/
+ @Nullable
PositionalKey getPositionalKey() {
return this.positionalKey;
}
@@ -484,8 +497,20 @@ public byte[] getKey() {
*
* @return can be {@literal null}.
*/
- @Nullable
- public T getValue() {
+ public @Nullable T getValue() {
+ return this.value;
+ }
+
+ /**
+ * Get the actual value of the command execution or raise an error if {@literal null}.
+ *
+ * @return can be {@literal null}.
+ * @throws IllegalArgumentException in case the value is {@literal null}.
+ * @since 4.0
+ */
+ public T getRequiredValue() {
+
+ Assert.notNull(this.value, "Expected non null value, but was null");
return this.value;
}
@@ -497,8 +522,7 @@ public T getValue() {
* @return the mapped value.
* @since 2.1
*/
- @Nullable
- public U mapValue(Function super T, ? extends U> mapper) {
+ public @Nullable U mapValue(Function super T, ? extends U> mapper) {
Assert.notNull(mapper, "Mapper function must not be null");
@@ -601,8 +625,8 @@ public List resultsAsListSortBy(byte[]... keys) {
* @param returnValue can be {@literal null}.
* @return can be {@literal null}.
*/
- @Nullable
- public T getFirstNonNullNotEmptyOrDefault(@Nullable T returnValue) {
+ @Contract("!null -> !null")
+ public @Nullable T getFirstNonNullNotEmptyOrDefault(@Nullable T returnValue) {
for (NodeResult nodeResult : nodeResults) {
if (nodeResult.getValue() != null) {
@@ -805,7 +829,7 @@ public Iterator iterator() {
*/
private class NodeExceptionCollector {
- private final Map exceptions = new HashMap<>();
+ private final Map exceptions = new HashMap<>();
/**
* @return {@code true} if the collector contains at least one exception.
@@ -814,7 +838,7 @@ public boolean hasExceptions() {
return !exceptions.isEmpty();
}
- public void addException(NodeExecution execution, Throwable throwable) {
+ public void addException(NodeExecution execution, @Nullable Throwable throwable) {
Throwable translated = throwable instanceof Exception e ? convertToDataAccessException(e) : throwable;
Throwable resolvedException = translated != null ? translated : throwable;
@@ -825,7 +849,7 @@ public void addException(NodeExecution execution, Throwable throwable) {
/**
* @return the collected exceptions.
*/
- public List extends Throwable> getExceptions() {
+ public List extends @Nullable Throwable> getExceptions() {
return new ArrayList<>(exceptions.values());
}
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ClusterInfo.java b/src/main/java/org/springframework/data/redis/connection/ClusterInfo.java
index 8d6179811c..d5b1fe2679 100644
--- a/src/main/java/org/springframework/data/redis/connection/ClusterInfo.java
+++ b/src/main/java/org/springframework/data/redis/connection/ClusterInfo.java
@@ -17,8 +17,8 @@
import java.util.Properties;
+import org.jspecify.annotations.Nullable;
import org.springframework.data.redis.core.types.RedisClientInfo.INFO;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -60,8 +60,7 @@ public ClusterInfo(Properties clusterProperties) {
* @see Info#STATE
* @return {@literal null} if no entry found for requested {@link Info#STATE}.
*/
- @Nullable
- public String getState() {
+ public @Nullable String getState() {
return get(Info.STATE);
}
@@ -69,8 +68,7 @@ public String getState() {
* @see Info#SLOTS_ASSIGNED
* @return {@literal null} if no entry found for requested {@link Info#SLOTS_ASSIGNED}.
*/
- @Nullable
- public Long getSlotsAssigned() {
+ public @Nullable Long getSlotsAssigned() {
return getLongValueOf(Info.SLOTS_ASSIGNED);
}
@@ -78,8 +76,7 @@ public Long getSlotsAssigned() {
* @see Info#SLOTS_OK
* @return {@literal null} if no entry found for requested {@link Info#SLOTS_OK}.
*/
- @Nullable
- public Long getSlotsOk() {
+ public @Nullable Long getSlotsOk() {
return getLongValueOf(Info.SLOTS_OK);
}
@@ -87,8 +84,7 @@ public Long getSlotsOk() {
* @see Info#SLOTS_PFAIL
* @return {@literal null} if no entry found for requested {@link Info#SLOTS_PFAIL}.
*/
- @Nullable
- public Long getSlotsPfail() {
+ public @Nullable Long getSlotsPfail() {
return getLongValueOf(Info.SLOTS_PFAIL);
}
@@ -96,8 +92,7 @@ public Long getSlotsPfail() {
* @see Info#SLOTS_FAIL
* @return {@literal null} if no entry found for requested {@link Info#SLOTS_FAIL}.
*/
- @Nullable
- public Long getSlotsFail() {
+ public @Nullable Long getSlotsFail() {
return getLongValueOf(Info.SLOTS_FAIL);
}
@@ -105,8 +100,7 @@ public Long getSlotsFail() {
* @see Info#KNOWN_NODES
* @return {@literal null} if no entry found for requested {@link Info#KNOWN_NODES}.
*/
- @Nullable
- public Long getKnownNodes() {
+ public @Nullable Long getKnownNodes() {
return getLongValueOf(Info.KNOWN_NODES);
}
@@ -114,8 +108,7 @@ public Long getKnownNodes() {
* @see Info#SIZE
* @return {@literal null} if no entry found for requested {@link Info#SIZE}.
*/
- @Nullable
- public Long getClusterSize() {
+ public @Nullable Long getClusterSize() {
return getLongValueOf(Info.SIZE);
}
@@ -123,8 +116,7 @@ public Long getClusterSize() {
* @see Info#CURRENT_EPOCH
* @return {@literal null} if no entry found for requested {@link Info#CURRENT_EPOCH}.
*/
- @Nullable
- public Long getCurrentEpoch() {
+ public @Nullable Long getCurrentEpoch() {
return getLongValueOf(Info.CURRENT_EPOCH);
}
@@ -132,8 +124,7 @@ public Long getCurrentEpoch() {
* @see Info#MESSAGES_SENT
* @return {@literal null} if no entry found for requested {@link Info#MESSAGES_SENT}.
*/
- @Nullable
- public Long getMessagesSent() {
+ public @Nullable Long getMessagesSent() {
return getLongValueOf(Info.MESSAGES_SENT);
}
@@ -141,8 +132,7 @@ public Long getMessagesSent() {
* @see Info#MESSAGES_RECEIVED
* @return {@literal null} if no entry found for requested {@link Info#MESSAGES_RECEIVED}.
*/
- @Nullable
- public Long getMessagesReceived() {
+ public @Nullable Long getMessagesReceived() {
return getLongValueOf(Info.MESSAGES_RECEIVED);
}
@@ -150,8 +140,7 @@ public Long getMessagesReceived() {
* @param info must not be null
* @return {@literal null} if no entry found for requested {@link INFO}.
*/
- @Nullable
- public String get(Info info) {
+ public @Nullable String get(Info info) {
Assert.notNull(info, "Cannot retrieve cluster information for 'null'");
return get(info.key);
@@ -161,15 +150,13 @@ public String get(Info info) {
* @param key must not be {@literal null} or {@literal empty}.
* @return {@literal null} if no entry found for requested {@code key}.
*/
- @Nullable
- public String get(String key) {
+ public @Nullable String get(String key) {
Assert.hasText(key, "Cannot get cluster information for 'empty' / 'null' key.");
return this.clusterProperties.getProperty(key);
}
- @Nullable
- private Long getLongValueOf(Info info) {
+ private @Nullable Long getLongValueOf(Info info) {
String value = get(info);
return value == null ? null : Long.valueOf(value);
diff --git a/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java b/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java
index 42436431f4..d519b93b28 100644
--- a/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java
+++ b/src/main/java/org/springframework/data/redis/connection/ClusterTopology.java
@@ -20,8 +20,8 @@
import java.util.LinkedHashSet;
import java.util.Set;
+import org.jspecify.annotations.Nullable;
import org.springframework.data.redis.ClusterStateFailureException;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -193,6 +193,7 @@ public RedisClusterNode lookup(String nodeId) {
* @return never {@literal null}.
* @throws ClusterStateFailureException
*/
+ @SuppressWarnings("NullAway")
public RedisClusterNode lookup(RedisClusterNode node) {
Assert.notNull(node, "RedisClusterNode must not be null");
diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultMessage.java b/src/main/java/org/springframework/data/redis/connection/DefaultMessage.java
index b96a0895f3..51a632f482 100644
--- a/src/main/java/org/springframework/data/redis/connection/DefaultMessage.java
+++ b/src/main/java/org/springframework/data/redis/connection/DefaultMessage.java
@@ -15,7 +15,7 @@
*/
package org.springframework.data.redis.connection;
-import org.springframework.lang.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
/**
diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultSortParameters.java b/src/main/java/org/springframework/data/redis/connection/DefaultSortParameters.java
index bd50f34ba6..d8a58448cc 100644
--- a/src/main/java/org/springframework/data/redis/connection/DefaultSortParameters.java
+++ b/src/main/java/org/springframework/data/redis/connection/DefaultSortParameters.java
@@ -19,7 +19,7 @@
import java.util.Collections;
import java.util.List;
-import org.springframework.lang.Nullable;
+import org.jspecify.annotations.Nullable;
/**
* Default implementation for {@link SortParameters}.
@@ -28,7 +28,7 @@
*/
public class DefaultSortParameters implements SortParameters {
- private @Nullable byte[] byPattern;
+ private byte @Nullable[] byPattern;
private @Nullable Range limit;
private final List getPattern = new ArrayList<>(4);
private @Nullable Order order;
@@ -61,7 +61,7 @@ public DefaultSortParameters(@Nullable Range limit, @Nullable Order order, @Null
* @param order
* @param alphabetic
*/
- public DefaultSortParameters(@Nullable byte[] byPattern, @Nullable Range limit, @Nullable byte[][] getPattern,
+ public DefaultSortParameters(byte @Nullable[] byPattern, @Nullable Range limit, byte @Nullable[][] getPattern,
@Nullable Order order, @Nullable Boolean alphabetic) {
super();
this.byPattern = byPattern;
@@ -71,8 +71,8 @@ public DefaultSortParameters(@Nullable byte[] byPattern, @Nullable Range limit,
setGetPattern(getPattern);
}
- @Nullable
- public byte[] getByPattern() {
+
+ public byte @Nullable[] getByPattern() {
return byPattern;
}
@@ -80,7 +80,7 @@ public void setByPattern(byte[] byPattern) {
this.byPattern = byPattern;
}
- public Range getLimit() {
+ public @Nullable Range getLimit() {
return limit;
}
@@ -92,12 +92,11 @@ public byte[][] getGetPattern() {
return getPattern.toArray(new byte[getPattern.size()][]);
}
- @Nullable
- public void addGetPattern(byte[] gPattern) {
+ public void addGetPattern(byte @Nullable[] gPattern) {
getPattern.add(gPattern);
}
- public void setGetPattern(@Nullable byte[][] gPattern) {
+ public void setGetPattern(byte @Nullable[][] gPattern) {
getPattern.clear();
if (gPattern == null) {
@@ -107,8 +106,7 @@ public void setGetPattern(@Nullable byte[][] gPattern) {
Collections.addAll(getPattern, gPattern);
}
- @Nullable
- public Order getOrder() {
+ public @Nullable Order getOrder() {
return order;
}
@@ -116,8 +114,7 @@ public void setOrder(Order order) {
this.order = order;
}
- @Nullable
- public Boolean isAlphabetic() {
+ public @Nullable Boolean isAlphabetic() {
return alphabetic;
}
diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java
index c2ea198d8b..50dfab46b9 100644
--- a/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/DefaultStringRedisConnection.java
@@ -23,7 +23,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
+import org.jspecify.annotations.NullUnmarked;
+import org.jspecify.annotations.Nullable;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
@@ -62,7 +63,6 @@
import org.springframework.data.redis.domain.geo.GeoShape;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -82,6 +82,7 @@
* @author Dennis Neufeld
* @author Shyngys Sapraliyev
*/
+@NullUnmarked
@SuppressWarnings({ "ConstantConditions", "deprecation" })
public class DefaultStringRedisConnection implements StringRedisConnection, DecoratedRedisConnection {
@@ -103,9 +104,8 @@ public class DefaultStringRedisConnection implements StringRedisConnection, Deco
private Converter>, GeoResults>> byteGeoResultsToStringGeoResults;
private Converter byteMapRecordToStringMapRecordConverter = new Converter() {
- @Nullable
@Override
- public StringRecord convert(ByteRecord source) {
+ public @Nullable StringRecord convert(ByteRecord source) {
return StringRecord.of(source.deserialize(serializer));
}
};
@@ -129,9 +129,8 @@ public String convert(byte[] source) {
private class SerializingConverter implements Converter {
- @Nullable
@Override
- public byte[] convert(String source) {
+ public byte @Nullable[] convert(String source) {
return serializer.serialize(source);
}
}
@@ -392,27 +391,25 @@ public byte[] get(byte[] key) {
return convertAndReturn(delegate.get(key), Converters.identityConverter());
}
- @Nullable
+
@Override
- public byte[] getDel(byte[] key) {
+ public byte @Nullable[] getDel(byte[] key) {
return convertAndReturn(delegate.getDel(key), Converters.identityConverter());
}
- @Nullable
@Override
- public String getDel(String key) {
+ public @Nullable String getDel(String key) {
return convertAndReturn(delegate.getDel(serialize(key)), bytesToString);
}
- @Nullable
+
@Override
- public byte[] getEx(byte[] key, Expiration expiration) {
+ public byte @Nullable[] getEx(byte[] key, Expiration expiration) {
return convertAndReturn(delegate.getEx(key, expiration), Converters.identityConverter());
}
- @Nullable
@Override
- public String getEx(String key, Expiration expiration) {
+ public @Nullable String getEx(String key, Expiration expiration) {
return convertAndReturn(delegate.getEx(serialize(key), expiration), bytesToString);
}
@@ -925,9 +922,8 @@ public Long bitOp(BitOperation op, byte[] destination, byte[]... keys) {
return convertAndReturn(delegate.bitOp(op, destination, keys), Converters.identityConverter());
}
- @Nullable
@Override
- public Long bitPos(byte[] key, boolean bit, org.springframework.data.domain.Range range) {
+ public @Nullable Long bitPos(byte[] key, boolean bit, org.springframework.data.domain.Range range) {
return convertAndReturn(delegate.bitPos(key, bit, range), Converters.identityConverter());
}
@@ -1006,82 +1002,69 @@ public Double zIncrBy(byte[] key, double increment, byte[] value) {
return convertAndReturn(delegate.zIncrBy(key, increment, value), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zDiff(byte[]... sets) {
+ public @Nullable Set zDiff(byte[]... sets) {
return convertAndReturn(delegate.zDiff(sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zDiffWithScores(byte[]... sets) {
+ public @Nullable Set zDiffWithScores(byte[]... sets) {
return convertAndReturn(delegate.zDiffWithScores(sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Long zDiffStore(byte[] destKey, byte[]... sets) {
+ public @Nullable Long zDiffStore(byte[] destKey, byte[]... sets) {
return convertAndReturn(delegate.zDiffStore(destKey, sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zDiff(String... sets) {
+ public @Nullable Set zDiff(String... sets) {
return convertAndReturn(delegate.zDiff(serializeMulti(sets)), byteSetToStringSet);
}
- @Nullable
@Override
- public Set zDiffWithScores(String... sets) {
+ public @Nullable Set zDiffWithScores(String... sets) {
return convertAndReturn(delegate.zDiffWithScores(serializeMulti(sets)), tupleToStringTuple);
}
- @Nullable
@Override
- public Long zDiffStore(String destKey, String... sets) {
+ public @Nullable Long zDiffStore(String destKey, String... sets) {
return convertAndReturn(delegate.zDiffStore(serialize(destKey), serializeMulti(sets)),
Converters.identityConverter());
}
- @Nullable
@Override
- public Set zInter(byte[]... sets) {
+ public @Nullable Set zInter(byte[]... sets) {
return convertAndReturn(delegate.zInter(sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zInterWithScores(byte[]... sets) {
+ public @Nullable Set zInterWithScores(byte[]... sets) {
return convertAndReturn(delegate.zInterWithScores(sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zInterWithScores(Aggregate aggregate, Weights weights, byte[]... sets) {
+ public @Nullable Set zInterWithScores(Aggregate aggregate, Weights weights, byte[]... sets) {
return convertAndReturn(delegate.zInterWithScores(aggregate, weights, sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zInter(String... sets) {
+ public @Nullable Set zInter(String... sets) {
return convertAndReturn(delegate.zInter(serializeMulti(sets)), byteSetToStringSet);
}
- @Nullable
@Override
- public Set zInterWithScores(String... sets) {
+ public @Nullable Set zInterWithScores(String... sets) {
return convertAndReturn(delegate.zInterWithScores(serializeMulti(sets)), tupleToStringTuple);
}
- @Nullable
@Override
- public Set zInterWithScores(Aggregate aggregate, Weights weights, String... sets) {
+ public @Nullable Set zInterWithScores(Aggregate aggregate, Weights weights, String... sets) {
return convertAndReturn(delegate.zInterWithScores(aggregate, weights, serializeMulti(sets)), tupleToStringTuple);
}
- @Nullable
@Override
- public Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
+ public @Nullable Long zInterStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
return convertAndReturn(delegate.zInterStore(destKey, aggregate, Weights.of(weights), sets),
Converters.identityConverter());
}
@@ -1249,39 +1232,33 @@ public List zMScore(byte[] key, byte[]... values) {
return convertAndReturn(delegate.zMScore(key, values), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zUnion(byte[]... sets) {
+ public @Nullable Set zUnion(byte[]... sets) {
return convertAndReturn(delegate.zUnion(sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zUnionWithScores(byte[]... sets) {
+ public @Nullable Set zUnionWithScores(byte[]... sets) {
return convertAndReturn(delegate.zUnionWithScores(sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zUnionWithScores(Aggregate aggregate, Weights weights, byte[]... sets) {
+ public @Nullable Set zUnionWithScores(Aggregate aggregate, Weights weights, byte[]... sets) {
return convertAndReturn(delegate.zUnionWithScores(aggregate, weights, sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Set zUnion(String... sets) {
+ public @Nullable Set zUnion(String... sets) {
return convertAndReturn(delegate.zUnion(serializeMulti(sets)), byteSetToStringSet);
}
- @Nullable
@Override
- public Set zUnionWithScores(String... sets) {
+ public @Nullable Set zUnionWithScores(String... sets) {
return convertAndReturn(delegate.zUnionWithScores(serializeMulti(sets)), tupleToStringTuple);
}
- @Nullable
@Override
- public Set zUnionWithScores(Aggregate aggregate, Weights weights, String... sets) {
+ public @Nullable Set zUnionWithScores(Aggregate aggregate, Weights weights, String... sets) {
return convertAndReturn(delegate.zUnionWithScores(aggregate, weights, serializeMulti(sets)), tupleToStringTuple);
}
@@ -1290,9 +1267,8 @@ public Long zUnionStore(byte[] destKey, Aggregate aggregate, Weights weights, by
return convertAndReturn(delegate.zUnionStore(destKey, aggregate, weights, sets), Converters.identityConverter());
}
- @Nullable
@Override
- public Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
+ public @Nullable Long zUnionStore(byte[] destKey, Aggregate aggregate, int[] weights, byte[]... sets) {
return convertAndReturn(delegate.zUnionStore(destKey, aggregate, Weights.of(weights), sets),
Converters.identityConverter());
}
@@ -1555,52 +1531,45 @@ public Double hIncrBy(String key, String field, double delta) {
return hIncrBy(serialize(key), serialize(field), delta);
}
- @Nullable
+
@Override
- public byte[] hRandField(byte[] key) {
+ public byte @Nullable[] hRandField(byte[] key) {
return convertAndReturn(delegate.hRandField(key), Converters.identityConverter());
}
- @Nullable
@Override
- public Entry hRandFieldWithValues(byte[] key) {
+ public @Nullable Entry hRandFieldWithValues(byte[] key) {
return convertAndReturn(delegate.hRandFieldWithValues(key), Converters.identityConverter());
}
- @Nullable
@Override
- public List hRandField(byte[] key, long count) {
+ public @Nullable List hRandField(byte[] key, long count) {
return convertAndReturn(delegate.hRandField(key, count), Converters.identityConverter());
}
- @Nullable
@Override
- public List> hRandFieldWithValues(byte[] key, long count) {
+ public @Nullable List> hRandFieldWithValues(byte[] key, long count) {
return convertAndReturn(delegate.hRandFieldWithValues(key, count), Converters.identityConverter());
}
- @Nullable
@Override
- public String hRandField(String key) {
+ public @Nullable String hRandField(String key) {
return convertAndReturn(delegate.hRandField(serialize(key)), bytesToString);
}
- @Nullable
@Override
- public Entry hRandFieldWithValues(String key) {
+ public @Nullable Entry hRandFieldWithValues(String key) {
return convertAndReturn(delegate.hRandFieldWithValues(serialize(key)),
(Converter, Entry>) this::convertEntry);
}
- @Nullable
@Override
- public List hRandField(String key, long count) {
+ public @Nullable List hRandField(String key, long count) {
return convertAndReturn(delegate.hRandField(serialize(key), count), byteListToStringList);
}
- @Nullable
@Override
- public List> hRandFieldWithValues(String key, long count) {
+ public @Nullable List> hRandFieldWithValues(String key, long count) {
return convertAndReturn(delegate.hRandFieldWithValues(serialize(key), count),
new ListConverter<>(this::convertEntry));
}
@@ -1945,9 +1914,8 @@ public Long bitOp(BitOperation op, String destination, String... keys) {
return bitOp(op, serialize(destination), serializeMulti(keys));
}
- @Nullable
@Override
- public Long bitPos(String key, boolean bit, org.springframework.data.domain.Range range) {
+ public @Nullable Long bitPos(String key, boolean bit, org.springframework.data.domain.Range range) {
return bitPos(serialize(key), bit, range);
}
@@ -1981,9 +1949,8 @@ public DataType type(String key) {
return type(serialize(key));
}
- @Nullable
@Override
- public Long touch(String... keys) {
+ public @Nullable Long touch(String... keys) {
return touch(serializeMulti(keys));
}
@@ -2022,75 +1989,63 @@ public Long zLexCount(byte[] key, org.springframework.data.domain.Range
return delegate.zLexCount(key, range);
}
- @Nullable
@Override
- public Tuple zPopMin(byte[] key) {
+ public @Nullable Tuple zPopMin(byte[] key) {
return delegate.zPopMin(key);
}
- @Nullable
@Override
- public StringTuple zPopMin(String key) {
+ public @Nullable StringTuple zPopMin(String key) {
return convertAndReturn(delegate.zPopMin(serialize(key)), tupleConverter);
}
- @Nullable
@Override
- public Set zPopMin(byte[] key, long count) {
+ public @Nullable Set zPopMin(byte[] key, long count) {
return delegate.zPopMin(key, count);
}
- @Nullable
@Override
- public Set zPopMin(String key, long count) {
+ public @Nullable Set zPopMin(String key, long count) {
return convertAndReturn(delegate.zPopMin(serialize(key), count), tupleToStringTuple);
}
- @Nullable
@Override
- public Tuple bZPopMin(byte[] key, long timeout, TimeUnit unit) {
+ public @Nullable Tuple bZPopMin(byte[] key, long timeout, TimeUnit unit) {
return delegate.bZPopMin(key, timeout, unit);
}
- @Nullable
@Override
- public StringTuple bZPopMin(String key, long timeout, TimeUnit unit) {
+ public @Nullable StringTuple bZPopMin(String key, long timeout, TimeUnit unit) {
return convertAndReturn(delegate.bZPopMin(serialize(key), timeout, unit), tupleConverter);
}
- @Nullable
@Override
- public Tuple zPopMax(byte[] key) {
+ public @Nullable Tuple zPopMax(byte[] key) {
return delegate.zPopMax(key);
}
- @Nullable
@Override
- public StringTuple zPopMax(String key) {
+ public @Nullable StringTuple zPopMax(String key) {
return convertAndReturn(delegate.zPopMax(serialize(key)), tupleConverter);
}
- @Nullable
@Override
- public Set zPopMax(byte[] key, long count) {
+ public @Nullable Set zPopMax(byte[] key, long count) {
return delegate.zPopMax(key, count);
}
- @Nullable
@Override
- public Set zPopMax(String key, long count) {
+ public @Nullable Set zPopMax(String key, long count) {
return convertAndReturn(delegate.zPopMax(serialize(key), count), tupleToStringTuple);
}
- @Nullable
@Override
- public Tuple bZPopMax(byte[] key, long timeout, TimeUnit unit) {
+ public @Nullable Tuple bZPopMax(byte[] key, long timeout, TimeUnit unit) {
return delegate.bZPopMax(key, timeout, unit);
}
- @Nullable
@Override
- public StringTuple bZPopMax(String key, long timeout, TimeUnit unit) {
+ public @Nullable StringTuple bZPopMax(String key, long timeout, TimeUnit unit) {
return convertAndReturn(delegate.bZPopMax(serialize(key), timeout, unit), tupleConverter);
}
@@ -3135,8 +3090,7 @@ public void setDeserializePipelineAndTxResults(boolean deserializePipelineAndTxR
}
@SuppressWarnings("unchecked")
- @Nullable
- private T convertAndReturn(@Nullable Object value, Converter converter) {
+ private @Nullable T convertAndReturn(@Nullable Object value, Converter converter) {
if (isFutureConversion()) {
diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java b/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java
index b35522c642..b73a22aa6e 100644
--- a/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java
+++ b/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java
@@ -17,10 +17,10 @@
import java.nio.charset.StandardCharsets;
+import org.jspecify.annotations.Nullable;
import org.springframework.data.redis.connection.StringRedisConnection.StringTuple;
import org.springframework.data.redis.connection.zset.DefaultTuple;
import org.springframework.data.redis.connection.zset.Tuple;
-import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java
index f3be7ab276..b5976bc082 100644
--- a/src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/DefaultedRedisConnection.java
@@ -23,6 +23,8 @@
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import org.jspecify.annotations.NullUnmarked;
+import org.jspecify.annotations.Nullable;
import org.springframework.data.geo.Circle;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.GeoResults;
@@ -49,7 +51,6 @@
import org.springframework.data.redis.core.types.RedisClientInfo;
import org.springframework.data.redis.domain.geo.GeoReference;
import org.springframework.data.redis.domain.geo.GeoShape;
-import org.springframework.lang.Nullable;
/**
* {@link DefaultedRedisConnection} provides method delegates to {@code Redis*Command} interfaces accessible via
@@ -69,6 +70,7 @@
* @since 2.0
*/
@Deprecated
+@NullUnmarked
public interface DefaultedRedisConnection extends RedisCommands, RedisCommandsProvider {
// KEY COMMANDS
diff --git a/src/main/java/org/springframework/data/redis/connection/FutureResult.java b/src/main/java/org/springframework/data/redis/connection/FutureResult.java
index 58da880234..d9b847bbc1 100644
--- a/src/main/java/org/springframework/data/redis/connection/FutureResult.java
+++ b/src/main/java/org/springframework/data/redis/connection/FutureResult.java
@@ -17,8 +17,8 @@
import java.util.function.Supplier;
+import org.jspecify.annotations.Nullable;
import org.springframework.core.convert.converter.Converter;
-import org.springframework.lang.Nullable;
/**
* The result of an asynchronous operation
@@ -95,8 +95,7 @@ public T getResultHolder() {
* @return The converted result or {@literal null}.
*/
@SuppressWarnings("unchecked")
- @Nullable
- public Object convert(@Nullable Object result) {
+ public @Nullable Object convert(@Nullable Object result) {
if (result == null) {
return computeDefaultResult(null);
@@ -105,8 +104,7 @@ public Object convert(@Nullable Object result) {
return computeDefaultResult(converter.convert(result));
}
- @Nullable
- private Object computeDefaultResult(@Nullable Object source) {
+ private @Nullable Object computeDefaultResult(@Nullable Object source) {
return source != null ? source : defaultConversionResult.get();
}
@@ -134,8 +132,7 @@ public void setStatus(boolean status) {
/**
* @return The result of the operation. Can be {@literal null}.
*/
- @Nullable
- public abstract Object get();
+ public abstract @Nullable Object get();
/**
* Indicate whether or not the actual result needs to be {@link #convert(Object) converted} before handing over.
diff --git a/src/main/java/org/springframework/data/redis/connection/MessageListener.java b/src/main/java/org/springframework/data/redis/connection/MessageListener.java
index 4857b45c6d..73fd726e89 100644
--- a/src/main/java/org/springframework/data/redis/connection/MessageListener.java
+++ b/src/main/java/org/springframework/data/redis/connection/MessageListener.java
@@ -15,7 +15,7 @@
*/
package org.springframework.data.redis.connection;
-import org.springframework.lang.Nullable;
+import org.jspecify.annotations.Nullable;
/**
* Listener of messages published in Redis. A MessageListener can implement {@link SubscriptionListener} to receive
@@ -34,5 +34,5 @@ public interface MessageListener {
* @param message message must not be {@literal null}.
* @param pattern pattern matching the channel (if specified) - can be {@literal null}.
*/
- void onMessage(Message message, @Nullable byte[] pattern);
+ void onMessage(Message message, byte @Nullable[] pattern);
}
diff --git a/src/main/java/org/springframework/data/redis/connection/NamedNode.java b/src/main/java/org/springframework/data/redis/connection/NamedNode.java
index 5ccf100762..65f51ad9de 100644
--- a/src/main/java/org/springframework/data/redis/connection/NamedNode.java
+++ b/src/main/java/org/springframework/data/redis/connection/NamedNode.java
@@ -15,7 +15,7 @@
*/
package org.springframework.data.redis.connection;
-import org.springframework.lang.Nullable;
+import org.jspecify.annotations.Nullable;
/**
* @author Christoph Strobl
diff --git a/src/main/java/org/springframework/data/redis/connection/PoolException.java b/src/main/java/org/springframework/data/redis/connection/PoolException.java
index 1dc6b89cbb..0c6ecb10ae 100644
--- a/src/main/java/org/springframework/data/redis/connection/PoolException.java
+++ b/src/main/java/org/springframework/data/redis/connection/PoolException.java
@@ -15,8 +15,8 @@
*/
package org.springframework.data.redis.connection;
+import org.jspecify.annotations.Nullable;
import org.springframework.core.NestedRuntimeException;
-import org.springframework.lang.Nullable;
/**
* Exception thrown when there are issues with a resource pool
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveGeoCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveGeoCommands.java
index 80c9fde257..9206f91efc 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveGeoCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveGeoCommands.java
@@ -28,6 +28,7 @@
import java.util.Optional;
import java.util.Set;
+import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.data.domain.Sort.Direction;
@@ -43,7 +44,6 @@
import org.springframework.data.redis.connection.RedisGeoCommands.GeoRadiusCommandArgs.Flag;
import org.springframework.data.redis.domain.geo.GeoReference;
import org.springframework.data.redis.domain.geo.GeoShape;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -183,8 +183,8 @@ default Mono geoAdd(ByteBuffer key, Collection> lo
*/
class GeoDistCommand extends KeyCommand {
- private final ByteBuffer from;
- private final ByteBuffer to;
+ private final @Nullable ByteBuffer from;
+ private final @Nullable ByteBuffer to;
private final Metric metric;
private GeoDistCommand(@Nullable ByteBuffer key, @Nullable ByteBuffer from, @Nullable ByteBuffer to,
@@ -280,16 +280,14 @@ public GeoDistCommand forKey(ByteBuffer key) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getFrom() {
+ public @Nullable ByteBuffer getFrom() {
return from;
}
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getTo() {
+ public @Nullable ByteBuffer getTo() {
return to;
}
@@ -828,8 +826,7 @@ public Optional getLimit() {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Point getPoint() {
+ public @Nullable Point getPoint() {
return point;
}
@@ -1161,8 +1158,7 @@ public Optional getLimit() {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getMember() {
+ public @Nullable ByteBuffer getMember() {
return member;
}
@@ -1319,13 +1315,11 @@ public Optional getArgs() {
return Optional.ofNullable(args);
}
- @Nullable
- public GeoReference getReference() {
+ public @Nullable GeoReference getReference() {
return reference;
}
- @Nullable
- public GeoShape getShape() {
+ public @Nullable GeoShape getShape() {
return shape;
}
}
@@ -1419,8 +1413,7 @@ public GeoSearchStoreCommand with(GeoSearchStoreCommandArgs args) {
return new GeoSearchStoreCommand(getKey(), getDestKey(), getReference(), getShape(), args);
}
- @Nullable
- public ByteBuffer getDestKey() {
+ public @Nullable ByteBuffer getDestKey() {
return destKey;
}
@@ -1428,13 +1421,11 @@ public Optional getArgs() {
return Optional.ofNullable(args);
}
- @Nullable
- public GeoReference getReference() {
+ public @Nullable GeoReference getReference() {
return reference;
}
- @Nullable
- public GeoShape getShape() {
+ public @Nullable GeoShape getShape() {
return shape;
}
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java
index 385b652f2b..44ca7e8429 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveHashCommands.java
@@ -29,6 +29,7 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
+import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.data.redis.connection.ReactiveRedisConnection.BooleanResponse;
@@ -40,7 +41,6 @@
import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.types.Expiration;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveHyperLogLogCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveHyperLogLogCommands.java
index cba1cc8fac..eddf4c29ac 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveHyperLogLogCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveHyperLogLogCommands.java
@@ -15,6 +15,7 @@
*/
package org.springframework.data.redis.connection;
+import org.jspecify.annotations.Nullable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -50,7 +51,7 @@ class PfAddCommand extends KeyCommand {
private final List values;
- private PfAddCommand(ByteBuffer key, List values) {
+ private PfAddCommand(@Nullable ByteBuffer key, List values) {
super(key);
this.values = values;
@@ -193,7 +194,7 @@ public List getKeys() {
}
@Override
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return null;
}
}
@@ -245,7 +246,7 @@ class PfMergeCommand extends KeyCommand {
private final List sourceKeys;
- private PfMergeCommand(ByteBuffer key, List sourceKeys) {
+ private PfMergeCommand(@Nullable ByteBuffer key, List sourceKeys) {
super(key);
this.sourceKeys = sourceKeys;
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java
index 3354cf9af1..69427921d0 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveKeyCommands.java
@@ -24,6 +24,7 @@
import java.util.Collection;
import java.util.List;
+import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.data.redis.connection.ReactiveRedisConnection.BooleanResponse;
@@ -34,7 +35,6 @@
import org.springframework.data.redis.core.KeyScanOptions;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.core.types.Expiration;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -59,7 +59,7 @@ class CopyCommand extends KeyCommand {
private final boolean replace;
private final @Nullable Integer database;
- public CopyCommand(ByteBuffer key, @Nullable ByteBuffer target, boolean replace, @Nullable Integer database) {
+ public CopyCommand(@Nullable ByteBuffer key, @Nullable ByteBuffer target, boolean replace, @Nullable Integer database) {
super(key);
this.target = target;
this.replace = replace;
@@ -117,8 +117,7 @@ public CopyCommand database(int database) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getTarget() {
+ public @Nullable ByteBuffer getTarget() {
return target;
}
@@ -129,8 +128,7 @@ public boolean isReplace() {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Integer getDatabase() {
+ public @Nullable Integer getDatabase() {
return database;
}
@@ -326,7 +324,7 @@ class RenameCommand extends KeyCommand {
private @Nullable ByteBuffer newKey;
- private RenameCommand(ByteBuffer key, @Nullable ByteBuffer newKey) {
+ private RenameCommand(@Nullable ByteBuffer key, @Nullable ByteBuffer newKey) {
super(key);
@@ -363,8 +361,7 @@ public RenameCommand to(ByteBuffer newKey) {
* @return can be {@literal null}.
* @since 2.5.7
*/
- @Nullable
- public ByteBuffer getNewKey() {
+ public @Nullable ByteBuffer getNewKey() {
return newKey;
}
}
@@ -600,8 +597,7 @@ public ExpireCommand expire(Duration timeout) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Duration getTimeout() {
+ public @Nullable Duration getTimeout() {
if (expiration.isUnixTimestamp() || expiration.isPersistent()) {
return null;
@@ -714,11 +710,11 @@ class ExpireAtCommand extends KeyCommand {
private @Nullable Instant expireAt;
private final ExpirationOptions options;
- private ExpireAtCommand(ByteBuffer key, Instant expireAt) {
+ private ExpireAtCommand(@Nullable ByteBuffer key, @Nullable Instant expireAt) {
this(key, expireAt, ExpirationOptions.none());
}
- private ExpireAtCommand(@Nullable ByteBuffer key, Instant expireAt, ExpirationOptions options) {
+ private ExpireAtCommand(@Nullable ByteBuffer key, @Nullable Instant expireAt, ExpirationOptions options) {
super(key);
@@ -764,8 +760,7 @@ public ExpireAtCommand withOptions(ExpirationOptions options) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Instant getExpireAt() {
+ public @Nullable Instant getExpireAt() {
return expireAt;
}
@@ -906,7 +901,7 @@ class MoveCommand extends KeyCommand {
private @Nullable Integer database;
- private MoveCommand(ByteBuffer key, @Nullable Integer database) {
+ private MoveCommand(@Nullable ByteBuffer key, @Nullable Integer database) {
super(key);
@@ -940,8 +935,7 @@ public MoveCommand timeout(int database) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Integer getDatabase() {
+ public @Nullable Integer getDatabase() {
return database;
}
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveListCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveListCommands.java
index d92a99a270..5cf150840d 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveListCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveListCommands.java
@@ -24,6 +24,7 @@
import java.util.Collections;
import java.util.List;
+import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.data.redis.connection.ReactiveRedisConnection.BooleanResponse;
import org.springframework.data.redis.connection.ReactiveRedisConnection.ByteBufferResponse;
@@ -33,7 +34,6 @@
import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse;
import org.springframework.data.redis.connection.ReactiveRedisConnection.RangeCommand;
import org.springframework.data.redis.connection.RedisListCommands.Position;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -399,18 +399,15 @@ public LPosCommand rank(Integer rank) {
return new LPosCommand(getKey(), element, count, rank);
}
- @Nullable
- public Integer getCount() {
+ public @Nullable Integer getCount() {
return count;
}
- @Nullable
- public Integer getRank() {
+ public @Nullable Integer getRank() {
return rank;
}
- @Nullable
- public ByteBuffer getElement() {
+ public @Nullable ByteBuffer getElement() {
return element;
}
}
@@ -608,16 +605,14 @@ public ByteBuffer getValue() {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Position getPosition() {
+ public @Nullable Position getPosition() {
return position;
}
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getPivot() {
+ public @Nullable ByteBuffer getPivot() {
return pivot;
}
}
@@ -723,18 +718,15 @@ public BLMoveCommand timeout(Duration timeout) {
return new BLMoveCommand(getKey(), destinationKey, from, to, timeout);
}
- @Nullable
- public ByteBuffer getDestinationKey() {
+ public @Nullable ByteBuffer getDestinationKey() {
return destinationKey;
}
- @Nullable
- public Direction getFrom() {
+ public @Nullable Direction getFrom() {
return from;
}
- @Nullable
- public Direction getTo() {
+ public @Nullable Direction getTo() {
return to;
}
}
@@ -756,8 +748,7 @@ private BLMoveCommand(@Nullable ByteBuffer sourceKey, @Nullable ByteBuffer desti
this.timeout = timeout;
}
- @Nullable
- public Duration getTimeout() {
+ public @Nullable Duration getTimeout() {
return timeout;
}
}
@@ -897,8 +888,7 @@ public LSetCommand forKey(ByteBuffer key) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getValue() {
+ public @Nullable ByteBuffer getValue() {
return value;
}
@@ -1020,8 +1010,7 @@ public Long getCount() {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getValue() {
+ public @Nullable ByteBuffer getValue() {
return value;
}
}
@@ -1288,7 +1277,7 @@ public BPopCommand blockingFor(Duration timeout) {
}
@Override
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return null;
}
@@ -1327,11 +1316,11 @@ public PopResult(List result) {
this.result = result;
}
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return ObjectUtils.isEmpty(result) ? null : result.get(0);
}
- public ByteBuffer getValue() {
+ public @Nullable ByteBuffer getValue() {
return ObjectUtils.isEmpty(result) ? null : result.get(1);
}
@@ -1407,7 +1396,7 @@ class RPopLPushCommand extends KeyCommand {
private final @Nullable ByteBuffer destination;
- private RPopLPushCommand(ByteBuffer key, @Nullable ByteBuffer destination) {
+ private RPopLPushCommand(@Nullable ByteBuffer key, @Nullable ByteBuffer destination) {
super(key);
this.destination = destination;
@@ -1443,8 +1432,7 @@ public RPopLPushCommand to(ByteBuffer destinationKey) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getDestination() {
+ public @Nullable ByteBuffer getDestination() {
return destination;
}
}
@@ -1488,7 +1476,7 @@ class BRPopLPushCommand extends KeyCommand {
private final @Nullable ByteBuffer destination;
private final Duration timeout;
- private BRPopLPushCommand(ByteBuffer key, @Nullable ByteBuffer destination, Duration timeout) {
+ private BRPopLPushCommand(@Nullable ByteBuffer key, @Nullable ByteBuffer destination, Duration timeout) {
super(key);
@@ -1539,8 +1527,7 @@ public BRPopLPushCommand blockingFor(Duration timeout) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getDestination() {
+ public @Nullable ByteBuffer getDestination() {
return destination;
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveNumberCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveNumberCommands.java
index 31f80cc460..170ac80745 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveNumberCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveNumberCommands.java
@@ -20,10 +20,10 @@
import java.nio.ByteBuffer;
+import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.data.redis.connection.ReactiveRedisConnection.KeyCommand;
import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -68,7 +68,7 @@ class IncrByCommand extends KeyCommand {
private @Nullable T value;
- private IncrByCommand(ByteBuffer key, @Nullable T value) {
+ private IncrByCommand(@Nullable ByteBuffer key, @Nullable T value) {
super(key);
this.value = value;
@@ -104,8 +104,7 @@ public IncrByCommand by(T value) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public T getValue() {
+ public @Nullable T getValue() {
return value;
}
}
@@ -148,7 +147,7 @@ class DecrByCommand extends KeyCommand {
private @Nullable T value;
- private DecrByCommand(ByteBuffer key, @Nullable T value) {
+ private DecrByCommand(@Nullable ByteBuffer key, @Nullable T value) {
super(key);
this.value = value;
}
@@ -183,8 +182,7 @@ public DecrByCommand by(T value) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public T getValue() {
+ public @Nullable T getValue() {
return value;
}
}
@@ -298,8 +296,7 @@ public HIncrByCommand forKey(ByteBuffer key) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public T getValue() {
+ public @Nullable T getValue() {
return value;
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java
index 5dfb6d9db8..f5cb48452e 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java
@@ -21,10 +21,10 @@
import java.nio.ByteBuffer;
import java.util.List;
+import org.jspecify.annotations.Nullable;
import org.springframework.data.domain.Range;
import org.springframework.data.domain.Range.Bound;
import org.springframework.data.redis.core.ScanOptions;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
@@ -205,7 +205,7 @@ public KeyCommand(@Nullable ByteBuffer key) {
}
@Override
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return key;
}
}
@@ -273,7 +273,7 @@ class RangeCommand extends KeyCommand {
* @param key must not be {@literal null}.
* @param range must not be {@literal null}.
*/
- private RangeCommand(ByteBuffer key, Range range) {
+ private RangeCommand(@Nullable ByteBuffer key, Range range) {
super(key);
this.range = range;
@@ -360,8 +360,7 @@ public I getInput() {
return this.input;
}
- @Nullable
- public O getOutput() {
+ public @Nullable O getOutput() {
return this.output;
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveSetCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveSetCommands.java
index 76911fd441..9fe40b8eee 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveSetCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveSetCommands.java
@@ -25,6 +25,7 @@
import java.util.List;
import java.util.Optional;
+import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.data.redis.connection.ReactiveRedisConnection.BooleanResponse;
import org.springframework.data.redis.connection.ReactiveRedisConnection.ByteBufferResponse;
@@ -35,7 +36,6 @@
import org.springframework.data.redis.connection.ReactiveRedisConnection.MultiValueResponse;
import org.springframework.data.redis.connection.ReactiveRedisConnection.NumericResponse;
import org.springframework.data.redis.core.ScanOptions;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -415,8 +415,7 @@ public SMoveCommand to(ByteBuffer destination) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getDestination() {
+ public @Nullable ByteBuffer getDestination() {
return destination;
}
@@ -663,8 +662,7 @@ public static SInterCommand keys(Collection keys) {
}
@Override
- @Nullable
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return null;
}
@@ -805,8 +803,7 @@ public static SUnionCommand keys(Collection keys) {
}
@Override
- @Nullable
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return null;
}
@@ -947,8 +944,7 @@ public static SDiffCommand keys(Collection keys) {
}
@Override
- @Nullable
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return null;
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java
index 2860dc691c..2af6cb326a 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java
@@ -26,6 +26,7 @@
import java.util.List;
import java.util.Map;
+import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.data.domain.Range;
import org.springframework.data.redis.connection.ReactiveRedisConnection.CommandResponse;
@@ -47,7 +48,6 @@
import org.springframework.data.redis.connection.stream.StreamOffset;
import org.springframework.data.redis.connection.stream.StreamReadOptions;
import org.springframework.data.redis.connection.stream.StreamRecords;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -137,8 +137,7 @@ public AcknowledgeCommand inGroup(String group) {
return new AcknowledgeCommand(getKey(), group, getRecordIds());
}
- @Nullable
- public String getGroup() {
+ public @Nullable String getGroup() {
return group;
}
@@ -327,8 +326,7 @@ public boolean isNoMkStream() {
* @return can be {@literal null}.
* @since 2.3
*/
- @Nullable
- public Long getMaxlen() {
+ public @Nullable Long getMaxlen() {
return maxlen;
}
@@ -352,8 +350,7 @@ public boolean isApproximateTrimming() {
* @return the minimum record Id to retain during trimming.
* @since 2.7
*/
- @Nullable
- public RecordId getMinId() {
+ public @Nullable RecordId getMinId() {
return minId;
}
@@ -405,6 +402,7 @@ default Mono xAdd(ByteBufferRecord record) {
* @see Redis Documentation: XADD
* @since 3.4
*/
+ @SuppressWarnings("NullAway")
default Mono xAdd(ByteBufferRecord record, XAddOptions xAddOptions) {
Assert.notNull(record, "Record must not be null");
@@ -709,7 +707,6 @@ Flux> xPendingSum
* @see Redis Documentation: xpending
* @since 2.3
*/
- @Nullable
default Mono xPending(ByteBuffer key, Consumer consumer) {
return xPending(key, consumer.getGroup(), consumer.getName());
}
@@ -724,7 +721,6 @@ default Mono xPending(ByteBuffer key, Consumer consumer) {
* @see Redis Documentation: xpending
* @since 2.3
*/
- @Nullable
default Mono xPending(ByteBuffer key, String groupName, String consumerName) {
return xPending(Mono.just(PendingRecordsCommand.pending(key, groupName).consumer(consumerName))).next()
.map(CommandResponse::getOutput);
@@ -807,7 +803,7 @@ class PendingRecordsCommand extends KeyCommand {
private final Range> range;
private final @Nullable Long count;
- private PendingRecordsCommand(ByteBuffer key, String groupName, @Nullable String consumerName, Range> range,
+ private PendingRecordsCommand(@Nullable ByteBuffer key, String groupName, @Nullable String consumerName, Range> range,
@Nullable Long count) {
super(key);
@@ -861,8 +857,7 @@ public String getGroupName() {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public String getConsumerName() {
+ public @Nullable String getConsumerName() {
return consumerName;
}
@@ -876,8 +871,7 @@ public Range> getRange() {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Long getCount() {
+ public @Nullable Long getCount() {
return count;
}
@@ -914,7 +908,7 @@ class RangeCommand extends KeyCommand {
* @param range must not be {@literal null}.
* @param limit must not be {@literal null}.
*/
- private RangeCommand(ByteBuffer key, Range range, Limit limit) {
+ private RangeCommand(@Nullable ByteBuffer key, Range range, Limit limit) {
super(key);
this.range = range;
@@ -1104,13 +1098,11 @@ public List> getStreamOffsets() {
return streamOffsets;
}
- @Nullable
- public StreamReadOptions getReadOptions() {
+ public @Nullable StreamReadOptions getReadOptions() {
return readOptions;
}
- @Nullable
- public Consumer getConsumer() {
+ public @Nullable Consumer getConsumer() {
return consumer;
}
}
@@ -1161,7 +1153,7 @@ class XInfoCommand extends KeyCommand {
private final @Nullable String groupName;
- private XInfoCommand(ByteBuffer key, @Nullable String groupName) {
+ private XInfoCommand(@Nullable ByteBuffer key, @Nullable String groupName) {
super(key);
this.groupName = groupName;
@@ -1178,8 +1170,7 @@ public XInfoCommand consumersIn(String groupName) {
return new XInfoCommand(getKey(), groupName);
}
- @Nullable
- public String getGroupName() {
+ public @Nullable String getGroupName() {
return groupName;
}
}
@@ -1308,18 +1299,15 @@ public boolean isMkStream() {
return this.mkStream;
}
- @Nullable
- public ReadOffset getReadOffset() {
+ public @Nullable ReadOffset getReadOffset() {
return this.offset;
}
- @Nullable
- public String getGroupName() {
+ public @Nullable String getGroupName() {
return groupName;
}
- @Nullable
- public String getConsumerName() {
+ public @Nullable String getConsumerName() {
return consumerName;
}
@@ -1369,7 +1357,6 @@ default Mono xGroupCreate(ByteBuffer key, String groupName, ReadOffset r
* @param consumerName the name of the consumer to remove from the group.
* @return the {@link Mono} emitting {@literal ok} if successful.
*/
- @Nullable
default Mono xGroupDelConsumer(ByteBuffer key, String groupName, String consumerName) {
return xGroupDelConsumer(key, Consumer.from(groupName, consumerName));
}
@@ -1392,7 +1379,6 @@ default Mono xGroupDelConsumer(ByteBuffer key, Consumer consumer) {
* @param groupName name of the consumer group.
* @return the {@link Mono} emitting {@literal ok} if successful.
*/
- @Nullable
default Mono xGroupDestroy(ByteBuffer key, String groupName) {
return xGroup(GroupCommand.destroyGroup(groupName).forStream(key));
}
@@ -1497,7 +1483,7 @@ class TrimCommand extends KeyCommand {
private @Nullable Long count;
private boolean approximateTrimming;
- private TrimCommand(ByteBuffer key, @Nullable Long count, boolean approximateTrimming) {
+ private TrimCommand(@Nullable ByteBuffer key, @Nullable Long count, boolean approximateTrimming) {
super(key);
this.count = count;
this.approximateTrimming = approximateTrimming;
@@ -1551,8 +1537,7 @@ public TrimCommand approximate(boolean approximateTrimming) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Long getCount() {
+ public @Nullable Long getCount() {
return count;
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveStringCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveStringCommands.java
index 3c1bfc8eea..19e512126a 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveStringCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveStringCommands.java
@@ -26,6 +26,7 @@
import java.util.Map;
import java.util.Optional;
+import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.data.domain.Range;
import org.springframework.data.redis.connection.ReactiveRedisConnection.BooleanResponse;
@@ -39,7 +40,6 @@
import org.springframework.data.redis.connection.RedisStringCommands.BitOperation;
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
import org.springframework.data.redis.core.types.Expiration;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -61,10 +61,10 @@ public interface ReactiveStringCommands {
class SetCommand extends KeyCommand {
private @Nullable ByteBuffer value;
- private Expiration expiration;
- private SetOption option;
+ private @Nullable Expiration expiration;
+ private @Nullable SetOption option;
- private SetCommand(ByteBuffer key, @Nullable ByteBuffer value, @Nullable Expiration expiration,
+ private SetCommand(@Nullable ByteBuffer key, @Nullable ByteBuffer value, @Nullable Expiration expiration,
@Nullable SetOption option) {
super(key);
@@ -129,8 +129,7 @@ public SetCommand withSetOption(SetOption option) {
/**
* @return
*/
- @Nullable
- public ByteBuffer getValue() {
+ public @Nullable ByteBuffer getValue() {
return value;
}
@@ -208,7 +207,6 @@ default Mono set(ByteBuffer key, ByteBuffer value, Expiration expiratio
* @see Redis Documentation: SET
* @since 3.5
*/
- @Nullable
default Mono setGet(ByteBuffer key, ByteBuffer value, Expiration expiration, SetOption option) {
Assert.notNull(key, "Key must not be null");
@@ -505,8 +503,7 @@ private MSetCommand(Map keyValuePairs) {
}
@Override
- @Nullable
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return null;
}
@@ -589,7 +586,7 @@ class AppendCommand extends KeyCommand {
private @Nullable ByteBuffer value;
- private AppendCommand(ByteBuffer key, @Nullable ByteBuffer value) {
+ private AppendCommand(@Nullable ByteBuffer key, @Nullable ByteBuffer value) {
super(key);
this.value = value;
@@ -625,8 +622,7 @@ public AppendCommand append(ByteBuffer value) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getValue() {
+ public @Nullable ByteBuffer getValue() {
return value;
}
}
@@ -694,7 +690,7 @@ class SetRangeCommand extends KeyCommand {
private @Nullable ByteBuffer value;
private @Nullable Long offset;
- private SetRangeCommand(ByteBuffer key, @Nullable ByteBuffer value, @Nullable Long offset) {
+ private SetRangeCommand(@Nullable ByteBuffer key, @Nullable ByteBuffer value, @Nullable Long offset) {
super(key);
this.value = value;
@@ -740,16 +736,14 @@ public SetRangeCommand atPosition(long index) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getValue() {
+ public @Nullable ByteBuffer getValue() {
return value;
}
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Long getOffset() {
+ public @Nullable Long getOffset() {
return offset;
}
}
@@ -792,7 +786,7 @@ class GetBitCommand extends KeyCommand {
private @Nullable Long offset;
- private GetBitCommand(ByteBuffer key, @Nullable Long offset) {
+ private GetBitCommand(@Nullable ByteBuffer key, @Nullable Long offset) {
super(key);
@@ -825,8 +819,7 @@ public GetBitCommand atOffset(long offset) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Long getOffset() {
+ public @Nullable Long getOffset() {
return offset;
}
}
@@ -866,7 +859,7 @@ class SetBitCommand extends KeyCommand {
private @Nullable Long offset;
private boolean value;
- private SetBitCommand(ByteBuffer key, Long offset, boolean value) {
+ private SetBitCommand(@Nullable ByteBuffer key, @Nullable Long offset, boolean value) {
super(key);
@@ -910,8 +903,7 @@ public SetBitCommand to(boolean bit) {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Long getOffset() {
+ public @Nullable Long getOffset() {
return offset;
}
@@ -957,7 +949,7 @@ class BitCountCommand extends KeyCommand {
private Range range;
- private BitCountCommand(ByteBuffer key, Range range) {
+ private BitCountCommand(@Nullable ByteBuffer key, Range range) {
super(key);
@@ -1052,7 +1044,7 @@ class BitFieldCommand extends KeyCommand {
private @Nullable BitFieldSubCommands subcommands;
- private BitFieldCommand(ByteBuffer key, @Nullable BitFieldSubCommands subcommands) {
+ private BitFieldCommand(@Nullable ByteBuffer key, @Nullable BitFieldSubCommands subcommands) {
super(key);
@@ -1086,7 +1078,7 @@ public BitFieldCommand commands(BitFieldSubCommands commands) {
return new BitFieldCommand(getKey(), commands);
}
- public BitFieldSubCommands getSubCommands() {
+ public @Nullable BitFieldSubCommands getSubCommands() {
return subcommands;
}
}
@@ -1198,8 +1190,7 @@ public List getKeys() {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public ByteBuffer getDestinationKey() {
+ public @Nullable ByteBuffer getDestinationKey() {
return destinationKey;
}
}
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveSubscription.java b/src/main/java/org/springframework/data/redis/connection/ReactiveSubscription.java
index 153d139e8f..9d2b37f024 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveSubscription.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveSubscription.java
@@ -15,13 +15,13 @@
*/
package org.springframework.data.redis.connection;
-import org.springframework.lang.Nullable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.nio.ByteBuffer;
import java.util.Set;
+import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java
index c4037e2c55..d96b283314 100644
--- a/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/ReactiveZSetCommands.java
@@ -32,6 +32,7 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
+import org.jspecify.annotations.Nullable;
import org.reactivestreams.Publisher;
import org.springframework.data.domain.Range;
import org.springframework.data.domain.Sort.Direction;
@@ -42,7 +43,6 @@
import org.springframework.data.redis.connection.zset.Weights;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.data.redis.util.ByteUtils;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -264,6 +264,7 @@ public boolean isReturnTotalChanged() {
* @return
* @see Redis Documentation: ZADD
*/
+ @SuppressWarnings("NullAway")
default Mono zAdd(ByteBuffer key, Double score, ByteBuffer value) {
Assert.notNull(key, "Key must not be null");
@@ -282,6 +283,7 @@ default Mono zAdd(ByteBuffer key, Double score, ByteBuffer value) {
* @return
* @see Redis Documentation: ZADD
*/
+ @SuppressWarnings("NullAway")
default Mono zAdd(ByteBuffer key, Collection extends Tuple> tuples) {
Assert.notNull(key, "Key must not be null");
@@ -473,8 +475,7 @@ public ByteBuffer getValue() {
/**
* @return can be {@literal null}.
*/
- @Nullable
- public Number getIncrement() {
+ public @Nullable Number getIncrement() {
return increment;
}
}
@@ -942,7 +943,7 @@ default Flux zRevRangeWithScores(ByteBuffer key, Range range) {
*/
class ZRangeStoreCommand extends KeyCommand {
- private final ByteBuffer destKey;
+ private final @Nullable ByteBuffer destKey;
private final RangeMode rangeMode;
private final Range> range;
private final Direction direction;
@@ -1054,7 +1055,7 @@ public ZRangeStoreCommand limit(Limit limit) {
return new ZRangeStoreCommand(getKey(), getDestKey(), rangeMode, range, direction, limit);
}
- public ByteBuffer getDestKey() {
+ public @Nullable ByteBuffer getDestKey() {
return destKey;
}
@@ -1832,13 +1833,11 @@ public PopDirection getDirection() {
return direction;
}
- @Nullable
- public Long getTimeout() {
+ public @Nullable Long getTimeout() {
return timeout;
}
- @Nullable
- public TimeUnit getTimeUnit() {
+ public @Nullable TimeUnit getTimeUnit() {
return timeUnit;
}
@@ -2161,7 +2160,7 @@ class ZRemRangeByRankCommand extends KeyCommand {
private final Range range;
- private ZRemRangeByRankCommand(ByteBuffer key, Range range) {
+ private ZRemRangeByRankCommand(@Nullable ByteBuffer key, Range range) {
super(key);
this.range = range;
}
@@ -2404,8 +2403,7 @@ public static ZDiffCommand sets(Collection keys) {
}
@Override
- @Nullable
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return null;
}
@@ -2610,9 +2608,8 @@ public ZAggregateCommand aggregateUsing(@Nullable Aggregate aggregateFunction) {
return new ZAggregateCommand(sourceKeys, weights, aggregateFunction);
}
- @Nullable
@Override
- public ByteBuffer getKey() {
+ public @Nullable ByteBuffer getKey() {
return null;
}
@@ -2865,7 +2862,7 @@ Flux>> zInterWithScores(
*/
class ZInterStoreCommand extends ZAggregateStoreCommand {
- private ZInterStoreCommand(ByteBuffer key, List sourceKeys, List weights,
+ private ZInterStoreCommand(@Nullable ByteBuffer key, List sourceKeys, List weights,
@Nullable Aggregate aggregate) {
super(key, sourceKeys, weights, aggregate);
}
diff --git a/src/main/java/org/springframework/data/redis/connection/RedisClusterCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisClusterCommands.java
index 018a78b6cb..24c2ddab03 100644
--- a/src/main/java/org/springframework/data/redis/connection/RedisClusterCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/RedisClusterCommands.java
@@ -19,6 +19,8 @@
import java.util.List;
import java.util.Map;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.NullUnmarked;
import org.springframework.data.redis.connection.RedisClusterNode.SlotRange;
/**
@@ -30,6 +32,7 @@
* @author Mark Paluch
* @since 1.7
*/
+@NullUnmarked
public interface RedisClusterCommands {
/**
@@ -38,7 +41,7 @@ public interface RedisClusterCommands {
* @return never {@literal null}.
* @see Redis Documentation: CLUSTER NODES
*/
- Iterable clusterGetNodes();
+ Iterable<@NonNull RedisClusterNode> clusterGetNodes();
/**
* Retrieve information about connected replicas for given master node.
@@ -47,7 +50,7 @@ public interface RedisClusterCommands {
* @return never {@literal null}.
* @see Redis Documentation: CLUSTER REPLICAS
*/
- Collection clusterGetReplicas(RedisClusterNode master);
+ Collection<@NonNull RedisClusterNode> clusterGetReplicas(@NonNull RedisClusterNode master);
/**
* Retrieve information about masters and their connected replicas.
@@ -55,7 +58,7 @@ public interface RedisClusterCommands {
* @return never {@literal null}.
* @see Redis Documentation: CLUSTER REPLICAS
*/
- Map> clusterGetMasterReplicaMap();
+ Map<@NonNull RedisClusterNode, @NonNull Collection<@NonNull RedisClusterNode>> clusterGetMasterReplicaMap();
/**
* Find the slot for a given {@code key}.
@@ -64,7 +67,7 @@ public interface RedisClusterCommands {
* @return
* @see Redis Documentation: CLUSTER KEYSLOT
*/
- Integer clusterGetSlotForKey(byte[] key);
+ Integer clusterGetSlotForKey(byte @NonNull [] key);
/**
* Find the {@link RedisClusterNode} serving given {@literal slot}.
@@ -80,7 +83,7 @@ public interface RedisClusterCommands {
* @param key must not be {@literal null}.
* @return
*/
- RedisClusterNode clusterGetNodeForKey(byte[] key);
+ RedisClusterNode clusterGetNodeForKey(byte @NonNull [] key);
/**
* Get cluster information.
@@ -97,7 +100,7 @@ public interface RedisClusterCommands {
* @param slots
* @see Redis Documentation: CLUSTER ADDSLOTS
*/
- void clusterAddSlots(RedisClusterNode node, int... slots);
+ void clusterAddSlots(@NonNull RedisClusterNode node, int @NonNull... slots);
/**
* Assign {@link SlotRange#getSlotsArray()} to given {@link RedisClusterNode}.
@@ -106,7 +109,7 @@ public interface RedisClusterCommands {
* @param range must not be {@literal null}.
* @see Redis Documentation: CLUSTER ADDSLOTS
*/
- void clusterAddSlots(RedisClusterNode node, SlotRange range);
+ void clusterAddSlots(@NonNull RedisClusterNode node, @NonNull SlotRange range);
/**
* Count the number of keys assigned to one {@literal slot}.
@@ -124,7 +127,7 @@ public interface RedisClusterCommands {
* @param slots
* @see Redis Documentation: CLUSTER DELSLOTS
*/
- void clusterDeleteSlots(RedisClusterNode node, int... slots);
+ void clusterDeleteSlots( @NonNull RedisClusterNode node, int @NonNull ... slots);
/**
* Removes {@link SlotRange#getSlotsArray()} from given {@link RedisClusterNode}.
@@ -133,7 +136,7 @@ public interface RedisClusterCommands {
* @param range must not be {@literal null}.
* @see Redis Documentation: CLUSTER DELSLOTS
*/
- void clusterDeleteSlotsInRange(RedisClusterNode node, SlotRange range);
+ void clusterDeleteSlotsInRange(@NonNull RedisClusterNode node, @NonNull SlotRange range);
/**
* Remove given {@literal node} from cluster.
@@ -141,7 +144,7 @@ public interface RedisClusterCommands {
* @param node must not be {@literal null}.
* @see Redis Documentation: CLUSTER FORGET
*/
- void clusterForget(RedisClusterNode node);
+ void clusterForget(@NonNull RedisClusterNode node);
/**
* Add given {@literal node} to cluster.
@@ -150,7 +153,7 @@ public interface RedisClusterCommands {
* not be {@literal null}.
* @see Redis Documentation: CLUSTER MEET
*/
- void clusterMeet(RedisClusterNode node);
+ void clusterMeet(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
@@ -158,7 +161,7 @@ public interface RedisClusterCommands {
* @param mode must not be{@literal null}.
* @see Redis Documentation: CLUSTER SETSLOT
*/
- void clusterSetSlot(RedisClusterNode node, int slot, AddSlots mode);
+ void clusterSetSlot(@NonNull RedisClusterNode node, int slot, @NonNull AddSlots mode);
/**
* Get {@literal keys} served by slot.
@@ -168,7 +171,7 @@ public interface RedisClusterCommands {
* @return
* @see Redis Documentation: CLUSTER GETKEYSINSLOT
*/
- List clusterGetKeysInSlot(int slot, Integer count);
+ List clusterGetKeysInSlot(int slot, @NonNull Integer count);
/**
* Assign a {@literal replica} to given {@literal master}.
@@ -177,7 +180,7 @@ public interface RedisClusterCommands {
* @param replica must not be {@literal null}.
* @see Redis Documentation: CLUSTER REPLICATE
*/
- void clusterReplicate(RedisClusterNode master, RedisClusterNode replica);
+ void clusterReplicate(@NonNull RedisClusterNode master, @NonNull RedisClusterNode replica);
enum AddSlots {
MIGRATING, IMPORTING, STABLE, NODE
diff --git a/src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java b/src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java
index 8960d32ae1..a0554a0e6e 100644
--- a/src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java
+++ b/src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java
@@ -22,10 +22,10 @@
import java.util.Map;
import java.util.Set;
+import org.jspecify.annotations.Nullable;
import org.springframework.core.env.MapPropertySource;
import org.springframework.core.env.PropertySource;
import org.springframework.data.redis.connection.RedisConfiguration.ClusterConfiguration;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.NumberUtils;
import org.springframework.util.ObjectUtils;
@@ -194,7 +194,7 @@ public void setMaxRedirects(int maxRedirects) {
}
@Override
- public Integer getMaxRedirects() {
+ public @Nullable Integer getMaxRedirects() {
return maxRedirects != null && maxRedirects > Integer.MIN_VALUE ? maxRedirects : null;
}
@@ -203,9 +203,8 @@ public void setUsername(@Nullable String username) {
this.username = username;
}
- @Nullable
@Override
- public String getUsername() {
+ public @Nullable String getUsername() {
return this.username;
}
diff --git a/src/main/java/org/springframework/data/redis/connection/RedisClusterConnection.java b/src/main/java/org/springframework/data/redis/connection/RedisClusterConnection.java
index 585780ecb1..09db27c9d7 100644
--- a/src/main/java/org/springframework/data/redis/connection/RedisClusterConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/RedisClusterConnection.java
@@ -18,9 +18,10 @@
import java.util.Collection;
import java.util.Set;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.NullUnmarked;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.ScanOptions;
-import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**
@@ -36,6 +37,7 @@
* @author Mark Paluch
* @since 1.7
*/
+@NullUnmarked
public interface RedisClusterConnection
extends RedisConnection, DefaultedRedisClusterConnection, RedisClusterCommandsProvider {
@@ -44,8 +46,7 @@ public interface RedisClusterConnection
* @return {@literal null} when used in pipeline / transaction.
* @see RedisConnectionCommands#ping()
*/
- @Nullable
- String ping(RedisClusterNode node);
+ String ping(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
@@ -53,8 +54,7 @@ public interface RedisClusterConnection
* @return {@literal null} when used in pipeline / transaction.
* @see RedisKeyCommands#keys(byte[])
*/
- @Nullable
- Set keys(RedisClusterNode node, byte[] pattern);
+ Set keys(@NonNull RedisClusterNode node, byte @NonNull [] pattern);
/**
* Use a {@link Cursor} to iterate over keys.
@@ -65,15 +65,14 @@ public interface RedisClusterConnection
* @since 2.1
* @see Redis Documentation: SCAN
*/
- Cursor scan(RedisClusterNode node, ScanOptions options);
+ Cursor scan(@NonNull RedisClusterNode node, @NonNull ScanOptions options);
/**
* @param node must not be {@literal null}.
* @return {@literal null} when no keys stored at node or when used in pipeline / transaction.
* @see RedisKeyCommands#randomKey()
*/
- @Nullable
- byte[] randomKey(RedisClusterNode node);
+ byte[] randomKey(@NonNull RedisClusterNode node);
/**
* Execute the given command for the {@code key} provided potentially appending args.
@@ -93,8 +92,7 @@ public interface RedisClusterConnection
* @return command result as delivered by the underlying Redis driver. Can be {@literal null}.
* @since 2.1
*/
- @Nullable
- default T execute(String command, byte[] key, Collection args) {
+ default T execute(@NonNull String command, byte @NonNull [] key, @NonNull Collection args) {
Assert.notNull(command, "Command must not be null");
Assert.notNull(key, "Key must not be null");
diff --git a/src/main/java/org/springframework/data/redis/connection/RedisClusterNode.java b/src/main/java/org/springframework/data/redis/connection/RedisClusterNode.java
index 7a6443d484..1ea2f6a02b 100644
--- a/src/main/java/org/springframework/data/redis/connection/RedisClusterNode.java
+++ b/src/main/java/org/springframework/data/redis/connection/RedisClusterNode.java
@@ -22,7 +22,7 @@
import java.util.LinkedHashSet;
import java.util.Set;
-import org.springframework.lang.Nullable;
+import org.jspecify.annotations.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
@@ -132,8 +132,7 @@ public boolean servesSlot(int slot) {
/**
* @return can be {@literal null}
*/
- @Nullable
- public LinkState getLinkState() {
+ public @Nullable LinkState getLinkState() {
return this.linkState;
}
@@ -216,8 +215,8 @@ public SlotRange(BitSet range) {
}
/**
- * Determines whether this {@link SlotRange} contains the given {@link Integer slot}, which implies
- * this cluster nodes manages the slot holding data stored in Redis.
+ * Determines whether this {@link SlotRange} contains the given {@link Integer slot}, which implies this cluster
+ * nodes manages the slot holding data stored in Redis.
*
* @param slot {@link Integer slot} to evaluate.
* @return true when slot is part of the range.
@@ -286,14 +285,8 @@ public enum LinkState {
*/
public enum Flag {
- MYSELF("myself"),
- MASTER("master"),
- REPLICA("slave"),
- FAIL("fail"),
- PFAIL("fail?"),
- HANDSHAKE("handshake"),
- NOADDR("noaddr"),
- NOFLAGS("noflags");
+ MYSELF("myself"), MASTER("master"), REPLICA("slave"), FAIL("fail"), PFAIL("fail?"), HANDSHAKE("handshake"), NOADDR(
+ "noaddr"), NOFLAGS("noflags");
private String raw;
@@ -388,12 +381,13 @@ public RedisClusterNodeBuilder linkState(LinkState linkState) {
}
@Override
+ @SuppressWarnings("NullAway")
public RedisClusterNode build() {
RedisNode base = super.build();
RedisClusterNode node;
- if (base.host != null) {
+ if (base.getHost() != null) {
node = new RedisClusterNode(base.getHost(), base.getPort(), slotRange);
} else {
node = new RedisClusterNode(slotRange);
@@ -402,7 +396,7 @@ public RedisClusterNode build() {
node.type = base.type;
node.masterId = base.masterId;
node.name = base.name;
- node.flags = flags;
+ node.flags = flags != null ? flags : Collections.emptySet();
node.linkState = linkState;
return node;
}
diff --git a/src/main/java/org/springframework/data/redis/connection/RedisClusterServerCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisClusterServerCommands.java
index 1bcac4c1f7..8b09e8eeee 100644
--- a/src/main/java/org/springframework/data/redis/connection/RedisClusterServerCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/RedisClusterServerCommands.java
@@ -19,6 +19,8 @@
import java.util.Properties;
import java.util.concurrent.TimeUnit;
+import org.jspecify.annotations.NonNull;
+import org.jspecify.annotations.NullUnmarked;
import org.springframework.data.redis.core.types.RedisClientInfo;
/**
@@ -26,45 +28,46 @@
* @author Dennis Neufeld
* @since 2.0
*/
+@NullUnmarked
public interface RedisClusterServerCommands extends RedisServerCommands {
/**
* @param node must not be {@literal null}.
* @see RedisServerCommands#bgReWriteAof()
*/
- void bgReWriteAof(RedisClusterNode node);
+ void bgReWriteAof(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
* @see RedisServerCommands#bgSave()
*/
- void bgSave(RedisClusterNode node);
+ void bgSave(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
* @return
* @see RedisServerCommands#lastSave()
*/
- Long lastSave(RedisClusterNode node);
+ Long lastSave(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
* @see RedisServerCommands#save()
*/
- void save(RedisClusterNode node);
+ void save(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
* @return
* @see RedisServerCommands#dbSize()
*/
- Long dbSize(RedisClusterNode node);
+ Long dbSize(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
* @see RedisServerCommands#flushDb()
*/
- void flushDb(RedisClusterNode node);
+ void flushDb(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
@@ -72,13 +75,13 @@ public interface RedisClusterServerCommands extends RedisServerCommands {
* @see RedisServerCommands#flushDb(FlushOption)
* @since 2.7
*/
- void flushDb(RedisClusterNode node, FlushOption option);
+ void flushDb(@NonNull RedisClusterNode node, @NonNull FlushOption option);
/**
* @param node must not be {@literal null}.
* @see RedisServerCommands#flushAll()
*/
- void flushAll(RedisClusterNode node);
+ void flushAll(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
@@ -86,14 +89,14 @@ public interface RedisClusterServerCommands extends RedisServerCommands {
* @see RedisServerCommands#flushAll(FlushOption)
* @since 2.7
*/
- void flushAll(RedisClusterNode node, FlushOption option);
+ void flushAll(@NonNull RedisClusterNode node, @NonNull FlushOption option);
/**
* @param node must not be {@literal null}.
* @return
* @see RedisServerCommands#info()
*/
- Properties info(RedisClusterNode node);
+ Properties info(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
@@ -101,13 +104,13 @@ public interface RedisClusterServerCommands extends RedisServerCommands {
* @return
* @see RedisServerCommands#info(String)
*/
- Properties info(RedisClusterNode node, String section);
+ Properties info(@NonNull RedisClusterNode node, @NonNull String section);
/**
* @param node must not be {@literal null}.
* @see RedisServerCommands#shutdown()
*/
- void shutdown(RedisClusterNode node);
+ void shutdown(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
@@ -115,7 +118,7 @@ public interface RedisClusterServerCommands extends RedisServerCommands {
* @return
* @see RedisServerCommands#getConfig(String)
*/
- Properties getConfig(RedisClusterNode node, String pattern);
+ Properties getConfig(@NonNull RedisClusterNode node, @NonNull String pattern);
/**
* @param node must not be {@literal null}.
@@ -123,27 +126,27 @@ public interface RedisClusterServerCommands extends RedisServerCommands {
* @param value
* @see RedisServerCommands#setConfig(String, String)
*/
- void setConfig(RedisClusterNode node, String param, String value);
+ void setConfig(@NonNull RedisClusterNode node, @NonNull String param, @NonNull String value);
/**
* @param node must not be {@literal null}.
* @see RedisServerCommands#resetConfigStats()
*/
- void resetConfigStats(RedisClusterNode node);
+ void resetConfigStats(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
* @see RedisServerCommands#rewriteConfig()
* @since 2.5
*/
- void rewriteConfig(RedisClusterNode node);
+ void rewriteConfig(@NonNull RedisClusterNode node);
/**
* @param node must not be {@literal null}.
* @return
* @see RedisServerCommands#time()
*/
- default Long time(RedisClusterNode node) {
+ default Long time(@NonNull RedisClusterNode node) {
return time(node, TimeUnit.MILLISECONDS);
}
@@ -154,12 +157,12 @@ default Long time(RedisClusterNode node) {
* @since 2.5
* @see RedisServerCommands#time(TimeUnit)
*/
- Long time(RedisClusterNode node, TimeUnit timeUnit);
+ Long time(@NonNull RedisClusterNode node, @NonNull TimeUnit timeUnit);
/**
* @param node must not be {@literal null}.
* @return
* @see RedisServerCommands#getClientList()
*/
- List getClientList(RedisClusterNode node);
+ List<@NonNull RedisClientInfo> getClientList(@NonNull RedisClusterNode node);
}
diff --git a/src/main/java/org/springframework/data/redis/connection/RedisCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisCommands.java
index 1ebb48b83f..0f76f567dc 100644
--- a/src/main/java/org/springframework/data/redis/connection/RedisCommands.java
+++ b/src/main/java/org/springframework/data/redis/connection/RedisCommands.java
@@ -15,7 +15,8 @@
*/
package org.springframework.data.redis.connection;
-import org.springframework.lang.Nullable;
+import org.jspecify.annotations.NullUnmarked;
+import org.jspecify.annotations.Nullable;
/**
* Interface defining the commands supported by Redis.
@@ -24,6 +25,7 @@
* @author Christoph Strobl
* @author Mark Paluch
*/
+@NullUnmarked
public interface RedisCommands extends RedisKeyCommands, RedisStringCommands, RedisListCommands, RedisSetCommands,
RedisZSetCommands, RedisHashCommands, RedisTxCommands, RedisPubSubCommands, RedisConnectionCommands,
RedisServerCommands, RedisStreamCommands, RedisScriptingCommands, RedisGeoCommands, RedisHyperLogLogCommands {
diff --git a/src/main/java/org/springframework/data/redis/connection/RedisConfiguration.java b/src/main/java/org/springframework/data/redis/connection/RedisConfiguration.java
index 053ce917de..2dfd8118ad 100644
--- a/src/main/java/org/springframework/data/redis/connection/RedisConfiguration.java
+++ b/src/main/java/org/springframework/data/redis/connection/RedisConfiguration.java
@@ -21,7 +21,8 @@
import java.util.function.IntSupplier;
import java.util.function.Supplier;
-import org.springframework.lang.Nullable;
+import org.jspecify.annotations.Nullable;
+import org.springframework.lang.Contract;
import org.springframework.util.Assert;
/**
@@ -68,6 +69,7 @@ default RedisPassword getPasswordOrElse(Supplier other) {
* @param configuration can be {@literal null}.
* @return {@code true} if given {@link RedisConfiguration} is instance of {@link WithPassword}.
*/
+ @Contract("null -> false")
static boolean isAuthenticationAware(@Nullable RedisConfiguration configuration) {
return configuration instanceof WithAuthentication;
}
@@ -76,6 +78,7 @@ static boolean isAuthenticationAware(@Nullable RedisConfiguration configuration)
* @param configuration can be {@literal null}.
* @return {@code true} if given {@link RedisConfiguration} is instance of {@link WithDatabaseIndex}.
*/
+ @Contract("null -> false")
static boolean isDatabaseIndexAware(@Nullable RedisConfiguration configuration) {
return configuration instanceof WithDatabaseIndex;
}
@@ -84,6 +87,7 @@ static boolean isDatabaseIndexAware(@Nullable RedisConfiguration configuration)
* @param configuration can be {@literal null}.
* @return {@code true} if given {@link RedisConfiguration} is instance of {@link SentinelConfiguration}.
*/
+ @Contract("null -> false")
static boolean isSentinelConfiguration(@Nullable RedisConfiguration configuration) {
return configuration instanceof SentinelConfiguration;
}
@@ -93,6 +97,7 @@ static boolean isSentinelConfiguration(@Nullable RedisConfiguration configuratio
* @return {@code true} if given {@link RedisConfiguration} is instance of {@link WithHostAndPort}.
* @since 2.1.6
*/
+ @Contract("null -> false")
static boolean isHostAndPortAware(@Nullable RedisConfiguration configuration) {
return configuration instanceof WithHostAndPort;
}
@@ -101,6 +106,7 @@ static boolean isHostAndPortAware(@Nullable RedisConfiguration configuration) {
* @param configuration can be {@literal null}.
* @return {@code true} if given {@link RedisConfiguration} is instance of {@link ClusterConfiguration}.
*/
+ @Contract("null -> false")
static boolean isClusterConfiguration(@Nullable RedisConfiguration configuration) {
return configuration instanceof ClusterConfiguration;
}
@@ -109,6 +115,7 @@ static boolean isClusterConfiguration(@Nullable RedisConfiguration configuration
* @param configuration can be {@literal null}.
* @return {@code true} if given {@link RedisConfiguration} is instance of {@link StaticMasterReplicaConfiguration}.
*/
+ @Contract("null -> false")
static boolean isStaticMasterReplicaConfiguration(@Nullable RedisConfiguration configuration) {
return configuration instanceof StaticMasterReplicaConfiguration;
}
@@ -117,6 +124,7 @@ static boolean isStaticMasterReplicaConfiguration(@Nullable RedisConfiguration c
* @param configuration can be {@literal null}.
* @return {@code true} if given {@link RedisConfiguration} is instance of {@link DomainSocketConfiguration}.
*/
+ @Contract("null -> false")
static boolean isDomainSocketConfiguration(@Nullable RedisConfiguration configuration) {
return configuration instanceof DomainSocketConfiguration;
}
@@ -141,8 +149,7 @@ static Integer getDatabaseOrElse(@Nullable RedisConfiguration configuration, Sup
* @return can be {@literal null}.
* @throws IllegalArgumentException if {@code other} is {@literal null}.
*/
- @Nullable
- static String getUsernameOrElse(@Nullable RedisConfiguration configuration, Supplier other) {
+ static @Nullable String getUsernameOrElse(@Nullable RedisConfiguration configuration, Supplier other) {
Assert.notNull(other, "Other must not be null");
return isAuthenticationAware(configuration) ? ((WithAuthentication) configuration).getUsername() : other.get();
@@ -227,7 +234,7 @@ default void setPassword(@Nullable String password) {
*
* @param password can be {@literal null}.
*/
- default void setPassword(@Nullable char[] password) {
+ default void setPassword(char @Nullable[] password) {
setPassword(RedisPassword.of(password));
}
@@ -418,8 +425,7 @@ default void setMaster(String name) {
* @return can be {@literal null} if not set.
* @since 2.4
*/
- @Nullable
- default String getDataNodeUsername() {
+ default @Nullable String getDataNodeUsername() {
return getUsername();
}
@@ -468,7 +474,7 @@ default void setSentinelPassword(@Nullable String password) {
* @param password can be {@literal null}.
* @since 2.2.2
*/
- default void setSentinelPassword(@Nullable char[] password) {
+ default void setSentinelPassword(char @Nullable[] password) {
setSentinelPassword(RedisPassword.of(password));
}
diff --git a/src/main/java/org/springframework/data/redis/connection/RedisConnection.java b/src/main/java/org/springframework/data/redis/connection/RedisConnection.java
index 69917d5391..0320d17a89 100644
--- a/src/main/java/org/springframework/data/redis/connection/RedisConnection.java
+++ b/src/main/java/org/springframework/data/redis/connection/RedisConnection.java
@@ -17,6 +17,8 @@
import java.util.List;
+import org.jspecify.annotations.NullUnmarked;
+import org.jspecify.annotations.Nullable;
import org.springframework.dao.DataAccessException;
/**
@@ -37,6 +39,7 @@
* @author James Howe
* @author John Blum
*/
+@NullUnmarked
public interface RedisConnection extends RedisCommandsProvider, DefaultedRedisConnection, AutoCloseable {
/**
@@ -102,7 +105,7 @@ public interface RedisConnection extends RedisCommandsProvider, DefaultedRedisCo
* @throws RedisPipelineException if the pipeline contains any incorrect/invalid statements
* @return the result of the executed commands.
*/
- List