Skip to content

Commit f3fece9

Browse files
christophstroblmp911de
authored andcommitted
Use to JSpecify for nullness checks.
Closes #3092 Original pull request: #3159
1 parent 0d09109 commit f3fece9

File tree

381 files changed

+4656
-5076
lines changed

Some content is hidden

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

381 files changed

+4656
-5076
lines changed

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

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

1818
import java.io.Serial;
1919

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

2223
/**
@@ -44,7 +45,7 @@ public class ClusterRedirectException extends DataRetrievalFailureException {
4445
* @param targetPort the port on the host.
4546
* @param e the root cause from the data access API in use.
4647
*/
47-
public ClusterRedirectException(int slot, String targetHost, int targetPort, Throwable e) {
48+
public ClusterRedirectException(int slot, String targetHost, int targetPort, @Nullable Throwable e) {
4849

4950
super("Redirect: slot %s to %s:%s.".formatted(slot, targetHost, targetPort), e);
5051

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

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

1818
import java.io.Serial;
1919

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

2223
/**
@@ -38,7 +39,7 @@ public class ClusterStateFailureException extends DataAccessResourceFailureExcep
3839
*
3940
* @param msg the detail message.
4041
*/
41-
public ClusterStateFailureException(String msg) {
42+
public ClusterStateFailureException(@Nullable String msg) {
4243
super(msg);
4344
}
4445

@@ -48,7 +49,7 @@ public ClusterStateFailureException(String msg) {
4849
* @param msg the detail message.
4950
* @param cause the nested exception.
5051
*/
51-
public ClusterStateFailureException(String msg, Throwable cause) {
52+
public ClusterStateFailureException(@Nullable String msg, @Nullable Throwable cause) {
5253
super(msg, cause);
5354
}
5455

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
*/
1616
package org.springframework.data.redis;
1717

18+
import org.jspecify.annotations.Nullable;
1819
import org.springframework.dao.DataAccessException;
19-
import org.springframework.lang.Nullable;
2020

2121
/**
2222
* Potentially translates an {@link Exception} into appropriate {@link DataAccessException}.

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

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

18+
import org.jspecify.annotations.Nullable;
1819
import org.springframework.core.convert.converter.Converter;
1920
import org.springframework.dao.DataAccessException;
20-
import org.springframework.lang.Nullable;
2121

2222
/**
2323
* {@link PassThroughExceptionTranslationStrategy} returns {@literal null} for unknown {@link Exception}s.
@@ -34,9 +34,8 @@ public PassThroughExceptionTranslationStrategy(Converter<Exception, DataAccessEx
3434
this.converter = converter;
3535
}
3636

37-
@Nullable
3837
@Override
39-
public DataAccessException translate(Exception e) {
38+
public @Nullable DataAccessException translate(Exception e) {
4039
return this.converter.convert(e);
4140
}
4241

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

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

18+
import org.jspecify.annotations.Nullable;
1819
import org.springframework.dao.DataAccessResourceFailureException;
1920

2021
/**
@@ -27,15 +28,15 @@ public class RedisConnectionFailureException extends DataAccessResourceFailureEx
2728
/**
2829
* @param msg the detail message.
2930
*/
30-
public RedisConnectionFailureException(String msg) {
31+
public RedisConnectionFailureException(@Nullable String msg) {
3132
super(msg);
3233
}
3334

3435
/**
3536
* @param msg the detail message.
3637
* @param cause the nested exception.
3738
*/
38-
public RedisConnectionFailureException(String msg, Throwable cause) {
39+
public RedisConnectionFailureException(@Nullable String msg, @Nullable Throwable cause) {
3940
super(msg, cause);
4041
}
4142

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

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

18+
import org.jspecify.annotations.Nullable;
1819
import org.springframework.dao.UncategorizedDataAccessException;
19-
import org.springframework.lang.Nullable;
2020

2121
/**
2222
* Exception thrown when we can't classify a Redis exception into one of Spring generic data access exceptions.
@@ -29,7 +29,7 @@ public class RedisSystemException extends UncategorizedDataAccessException {
2929
* @param msg the detail message.
3030
* @param cause the root cause from the data access API in use.
3131
*/
32-
public RedisSystemException(String msg, @Nullable Throwable cause) {
32+
public RedisSystemException(@Nullable String msg, @Nullable Throwable cause) {
3333
super(msg, cause);
3434
}
3535

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

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

1818
import java.io.Serial;
1919

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

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

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

src/main/java/org/springframework/data/redis/aot/RedisRuntimeHints.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Arrays;
1919
import java.util.function.Consumer;
2020

21+
import org.jspecify.annotations.Nullable;
2122
import org.springframework.aot.hint.MemberCategory;
2223
import org.springframework.aot.hint.RuntimeHints;
2324
import org.springframework.aot.hint.RuntimeHintsRegistrar;
@@ -50,7 +51,6 @@
5051
import org.springframework.data.redis.repository.query.RedisPartTreeQuery;
5152
import org.springframework.data.redis.repository.query.RedisQueryCreator;
5253
import org.springframework.data.redis.repository.support.RedisRepositoryFactoryBean;
53-
import org.springframework.lang.Nullable;
5454
import org.springframework.util.ClassUtils;
5555

5656
/**

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.function.Function;
2929
import java.util.function.Supplier;
3030

31+
import org.jspecify.annotations.Nullable;
3132
import org.springframework.dao.PessimisticLockingFailureException;
3233
import org.springframework.data.redis.connection.ReactiveRedisConnection;
3334
import org.springframework.data.redis.connection.ReactiveRedisConnectionFactory;
@@ -38,7 +39,6 @@
3839
import org.springframework.data.redis.connection.RedisStringCommands.SetOption;
3940
import org.springframework.data.redis.core.types.Expiration;
4041
import org.springframework.data.redis.util.ByteUtils;
41-
import org.springframework.lang.Nullable;
4242
import org.springframework.util.Assert;
4343
import org.springframework.util.ClassUtils;
4444
import org.springframework.util.ObjectUtils;
@@ -142,8 +142,9 @@ public byte[] get(String name, byte[] key, @Nullable Duration ttl) {
142142
return execute(name, connection -> doGet(connection, name, key, ttl));
143143
}
144144

145-
@Nullable
146-
private byte[] doGet(RedisConnection connection, String name, byte[] key, @Nullable Duration ttl) {
145+
146+
@SuppressWarnings("NullAway")
147+
private byte @Nullable[] doGet(RedisConnection connection, String name, byte[] key, @Nullable Duration ttl) {
147148

148149
byte[] result = shouldExpireWithin(ttl) ? connection.stringCommands().getEx(key, Expiration.from(ttl))
149150
: connection.stringCommands().get(key);
@@ -241,6 +242,7 @@ public void put(String name, byte[] key, byte[] value, @Nullable Duration ttl) {
241242

242243
}
243244

245+
@SuppressWarnings("NullAway")
244246
private void doPut(RedisConnection connection, String name, byte[] key, byte[] value, @Nullable Duration ttl) {
245247

246248
if (shouldExpireWithin(ttl)) {
@@ -265,6 +267,7 @@ public CompletableFuture<Void> store(String name, byte[] key, byte[] value, @Nul
265267
}
266268

267269
@Override
270+
@SuppressWarnings("NullAway")
268271
public byte[] putIfAbsent(String name, byte[] key, byte[] value, @Nullable Duration ttl) {
269272

270273
Assert.notNull(name, "Name must not be null");
@@ -538,6 +541,7 @@ public boolean isSupported() {
538541
}
539542

540543
@Override
544+
@SuppressWarnings("NullAway")
541545
public CompletableFuture<byte[]> retrieve(String name, byte[] key, @Nullable Duration ttl) {
542546

543547
return doWithConnection(connection -> {
@@ -572,6 +576,7 @@ private Mono<Boolean> doStoreWithLocking(String name, byte[] key, byte[] value,
572576
unused -> doUnlock(name, connection));
573577
}
574578

579+
@SuppressWarnings("NullAway")
575580
private Mono<Boolean> doStore(byte[] cacheKey, byte[] value, @Nullable Duration ttl,
576581
ReactiveRedisConnection connection) {
577582

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import java.time.Duration;
1919

20+
import org.jspecify.annotations.Nullable;
2021
import org.springframework.data.redis.cache.RedisCacheWriter.TtlFunction;
21-
import org.springframework.lang.Nullable;
2222

2323
/**
2424
* {@link TtlFunction} implementation returning the given, predetermined {@link Duration} used for per cache entry

0 commit comments

Comments
 (0)