Skip to content

Commit 7997567

Browse files
tmp save 3
1 parent 71ec6d4 commit 7997567

37 files changed

+778
-654
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.data.redis.TooManyClusterRedirectionsException;
3636
import org.springframework.data.redis.connection.util.ByteArraySet;
3737
import org.springframework.data.redis.connection.util.ByteArrayWrapper;
38+
import org.springframework.lang.Contract;
3839
import org.springframework.util.Assert;
3940
import org.springframework.util.CollectionUtils;
4041
import org.springframework.util.ObjectUtils;
@@ -598,6 +599,7 @@ public List<T> resultsAsListSortBy(byte[]... keys) {
598599
* @param returnValue can be {@literal null}.
599600
* @return can be {@literal null}.
600601
*/
602+
@Contract("!null -> !null")
601603
public @Nullable T getFirstNonNullNotEmptyOrDefault(@Nullable T returnValue) {
602604

603605
for (NodeResult<T> nodeResult : nodeResults) {

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

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

2424
import org.apache.commons.logging.Log;
2525
import org.apache.commons.logging.LogFactory;
26+
import org.jspecify.annotations.NullUnmarked;
2627
import org.jspecify.annotations.Nullable;
2728
import org.springframework.core.convert.converter.Converter;
2829
import org.springframework.data.geo.Circle;
@@ -81,6 +82,7 @@
8182
* @author Dennis Neufeld
8283
* @author Shyngys Sapraliyev
8384
*/
85+
@NullUnmarked
8486
@SuppressWarnings({ "ConstantConditions", "deprecation" })
8587
public class DefaultStringRedisConnection implements StringRedisConnection, DecoratedRedisConnection {
8688

@@ -127,7 +129,6 @@ public String convert(byte[] source) {
127129

128130
private class SerializingConverter implements Converter<String, byte[]> {
129131

130-
131132
@Override
132133
public byte @Nullable[] convert(String source) {
133134
return serializer.serialize(source);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Set;
2424
import java.util.concurrent.TimeUnit;
2525

26+
import org.jspecify.annotations.NullUnmarked;
2627
import org.jspecify.annotations.Nullable;
2728
import org.springframework.data.geo.Circle;
2829
import org.springframework.data.geo.Distance;
@@ -69,6 +70,7 @@
6970
* @since 2.0
7071
*/
7172
@Deprecated
73+
@NullUnmarked
7274
public interface DefaultedRedisConnection extends RedisCommands, RedisCommandsProvider {
7375

7476
// KEY COMMANDS

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.List;
1919

2020
import org.jspecify.annotations.NullUnmarked;
21+
import org.jspecify.annotations.Nullable;
2122
import org.springframework.dao.DataAccessException;
2223

2324
/**
@@ -104,7 +105,7 @@ public interface RedisConnection extends RedisCommandsProvider, DefaultedRedisCo
104105
* @throws RedisPipelineException if the pipeline contains any incorrect/invalid statements
105106
* @return the result of the executed commands.
106107
*/
107-
List<Object> closePipeline() throws RedisPipelineException;
108+
List<@Nullable Object> closePipeline() throws RedisPipelineException;
108109

109110
/**
110111
* @return the {@link RedisSentinelConnection} when using Redis Sentinel.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ default Long geoAdd(byte @NonNull [] key, @NonNull GeoLocation<byte[]> location)
8383
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
8484
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
8585
*/
86-
Long geoAdd(byte @NonNull [] key, Map<byte @NonNull [], @NonNull Point> memberCoordinateMap);
86+
Long geoAdd(byte @NonNull [] key, @NonNull Map<byte @NonNull [], @NonNull Point> memberCoordinateMap);
8787

8888
/**
8989
* Add {@link GeoLocation}s to {@literal key}
@@ -93,7 +93,7 @@ default Long geoAdd(byte @NonNull [] key, @NonNull GeoLocation<byte[]> location)
9393
* @return Number of elements added. {@literal null} when used in pipeline / transaction.
9494
* @see <a href="https://redis.io/commands/geoadd">Redis Documentation: GEOADD</a>
9595
*/
96-
Long geoAdd(byte @NonNull [] key, Iterable<@NonNull GeoLocation<byte[]>> locations);
96+
Long geoAdd(byte @NonNull [] key, @NonNull Iterable<@NonNull GeoLocation<byte[]>> locations);
9797

9898
/**
9999
* Get the {@link Distance} between {@literal member1} and {@literal member2}.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public interface RedisHashCommands {
7979
* @return empty {@link List} if key does not exist. {@literal null} when used in pipeline / transaction.
8080
* @see <a href="https://redis.io/commands/hmget">Redis Documentation: HMGET</a>
8181
*/
82-
List<byte @NonNull []> hMGet(byte @NonNull [] key, byte @NonNull [] @NonNull... fields);
82+
List<byte[]> hMGet(byte @NonNull [] key, byte @NonNull [] @NonNull... fields);
8383

8484
/**
8585
* Set multiple hash fields to multiple values using data provided in {@code hashes}
@@ -214,7 +214,7 @@ public interface RedisHashCommands {
214214
* @since 2.6
215215
* @see <a href="https://redis.io/commands/hrandfield">Redis Documentation: HRANDFIELD</a>
216216
*/
217-
List<Map.Entry<byte @NonNull [], byte @NonNull []>> hRandFieldWithValues(byte @NonNull [] key, long count);
217+
List<Map. @NonNull Entry<byte @NonNull [], byte @NonNull []>> hRandFieldWithValues(byte @NonNull [] key, long count);
218218

219219
/**
220220
* Use a {@link Cursor} to iterate over entries in hash at {@code key}.
@@ -225,7 +225,7 @@ public interface RedisHashCommands {
225225
* @since 1.4
226226
* @see <a href="https://redis.io/commands/hscan">Redis Documentation: HSCAN</a>
227227
*/
228-
Cursor<Map.Entry<byte @NonNull [], byte @NonNull []>> hScan(byte @NonNull [] key, ScanOptions options);
228+
Cursor<Map. @NonNull Entry<byte @NonNull [], byte @NonNull []>> hScan(byte @NonNull [] key, ScanOptions options);
229229

230230
/**
231231
* Returns the length of the value associated with {@code field} in the hash stored at {@code key}. If the {@code key}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import org.jspecify.annotations.NonNull;
2525
import org.jspecify.annotations.NullUnmarked;
26+
import org.jspecify.annotations.Nullable;
2627
import org.springframework.data.redis.core.Cursor;
2728
import org.springframework.data.redis.core.KeyScanOptions;
2829
import org.springframework.data.redis.core.ScanOptions;
@@ -153,7 +154,7 @@ default Boolean exists(byte @NonNull [] key) {
153154
* @return {@literal null} if no keys available or when used in pipeline or transaction.
154155
* @see <a href="https://redis.io/commands/randomkey">Redis Documentation: RANDOMKEY</a>
155156
*/
156-
byte @NonNull [] randomKey();
157+
byte[] randomKey();
157158

158159
/**
159160
* Rename key {@code oldKey} to {@code newKey}.
@@ -456,22 +457,22 @@ default Boolean pExpireAt(byte @NonNull [] key, @NonNull Instant unixTime) {
456457
* Sort the elements for {@code key}.
457458
*
458459
* @param key must not be {@literal null}.
459-
* @param params must not be {@literal null}.
460+
* @param params can be {@literal null}.
460461
* @return {@literal null} when used in pipeline / transaction.
461462
* @see <a href="https://redis.io/commands/sort">Redis Documentation: SORT</a>
462463
*/
463-
List<byte @NonNull []> sort(byte @NonNull [] key, @NonNull SortParameters params);
464+
List<byte @NonNull []> sort(byte @NonNull [] key, @Nullable SortParameters params);
464465

465466
/**
466467
* Sort the elements for {@code key} and store result in {@code storeKey}.
467468
*
468469
* @param key must not be {@literal null}.
469-
* @param params must not be {@literal null}.
470+
* @param params can be {@literal null}.
470471
* @param storeKey must not be {@literal null}.
471472
* @return {@literal null} when used in pipeline / transaction.
472473
* @see <a href="https://redis.io/commands/sort">Redis Documentation: SORT</a>
473474
*/
474-
Long sort(byte @NonNull [] key, @NonNull SortParameters params, byte @NonNull [] storeKey);
475+
Long sort(byte @NonNull [] key, @Nullable SortParameters params, byte @NonNull [] storeKey);
475476

476477
/**
477478
* Retrieve serialized version of the value stored at {@code key}.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ default Long lPos(byte @NonNull [] key, byte @NonNull [] element) {
105105
* @see <a href="https://redis.io/commands/lpos">Redis Documentation: LPOS</a>
106106
* @since 2.4
107107
*/
108-
List<Long> lPos(byte @NonNull [] key, byte[] element, @Nullable Integer rank, @Nullable Integer count);
108+
List<Long> lPos(byte @NonNull [] key, byte @NonNull[] element, @Nullable Integer rank, @Nullable Integer count);
109109

110110
/**
111111
* Prepend {@code values} to {@code key}.

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ enum FlushOption {
155155
/**
156156
* Shutdown server.
157157
*
158+
* @param option shutdown options if applicable.
158159
* @see <a href="https://redis.io/commands/shutdown">Redis Documentation: SHUTDOWN</a>
159160
* @since 1.3
160161
*/
161-
void shutdown(@NonNull ShutdownOption option);
162+
void shutdown(@Nullable ShutdownOption option);
162163

163164
/**
164165
* Load configuration parameters for given {@code pattern} from server.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ public boolean isLimited() {
901901
* @see <a href="https://redis.io/commands/xread">Redis Documentation: XREAD</a>
902902
*/
903903
List<@NonNull ByteRecord> xRead(@NonNull StreamReadOptions readOptions,
904-
StreamOffset<byte @NonNull []> @NonNull... streams);
904+
@NonNull StreamOffset<byte[]> @NonNull... streams);
905905

906906
/**
907907
* Read records from one or more {@link StreamOffset}s using a consumer group.
@@ -912,7 +912,7 @@ public boolean isLimited() {
912912
* @see <a href="https://redis.io/commands/xreadgroup">Redis Documentation: XREADGROUP</a>
913913
*/
914914
default List<@NonNull ByteRecord> xReadGroup(@NonNull Consumer consumer,
915-
StreamOffset<byte @NonNull []> @NonNull... streams) {
915+
@NonNull StreamOffset<byte[]> @NonNull... streams) {
916916
return xReadGroup(consumer, StreamReadOptions.empty(), streams);
917917
}
918918

@@ -926,7 +926,7 @@ public boolean isLimited() {
926926
* @see <a href="https://redis.io/commands/xreadgroup">Redis Documentation: XREADGROUP</a>
927927
*/
928928
List<@NonNull ByteRecord> xReadGroup(@NonNull Consumer consumer, @NonNull StreamReadOptions readOptions,
929-
StreamOffset<byte @NonNull []> @NonNull... streams);
929+
@NonNull StreamOffset<byte[]> @NonNull... streams);
930930

931931
/**
932932
* Read records from a stream within a specific {@link Range} in reverse order.

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.jspecify.annotations.NonNull;
2323
import org.jspecify.annotations.NullUnmarked;
24+
import org.jspecify.annotations.Nullable;
2425
import org.springframework.data.domain.Range;
2526
import org.springframework.data.redis.core.types.Expiration;
2627

@@ -71,7 +72,7 @@ enum BitOperation {
7172
* @see <a href="https://redis.io/commands/getex">Redis Documentation: GETEX</a>
7273
* @since 2.6
7374
*/
74-
byte[] getEx(byte @NonNull [] key, Expiration expiration);
75+
byte[] getEx(byte @NonNull [] key, @NonNull Expiration expiration);
7576

7677
/**
7778
* Set {@code value} of {@code key} and return its old value.
@@ -91,7 +92,7 @@ enum BitOperation {
9192
* @return {@literal null} when used in pipeline / transaction.
9293
* @see <a href="https://redis.io/commands/mget">Redis Documentation: MGET</a>
9394
*/
94-
List<byte @NonNull []> mGet(byte @NonNull [] @NonNull... keys);
95+
List<byte[]> mGet(byte @NonNull [] @NonNull... keys);
9596

9697
/**
9798
* Set {@code value} for {@code key}.
@@ -174,7 +175,7 @@ byte[] setGet(byte @NonNull [] key, byte @NonNull [] value, @NonNull Expiration
174175
* @return {@literal null} when used in pipeline / transaction.
175176
* @see <a href="https://redis.io/commands/mset">Redis Documentation: MSET</a>
176177
*/
177-
Boolean mSet(Map<byte @NonNull [], byte @NonNull []> tuple);
178+
Boolean mSet(@NonNull Map<byte @NonNull [], byte @NonNull []> tuple);
178179

179180
/**
180181
* Set multiple keys to multiple values using key-value pairs provided in {@code tuple} only if the provided key does
@@ -184,7 +185,7 @@ byte[] setGet(byte @NonNull [] key, byte @NonNull [] value, @NonNull Expiration
184185
* @return {@literal null} when used in pipeline / transaction.
185186
* @see <a href="https://redis.io/commands/msetnx">Redis Documentation: MSETNX</a>
186187
*/
187-
Boolean mSetNX(Map<byte @NonNull [], byte @NonNull []> tuple);
188+
Boolean mSetNX( @NonNull Map<byte @NonNull [], byte @NonNull []> tuple);
188189

189190
/**
190191
* Increment an integer value stored as string value of {@code key} by 1.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ Long zRemRangeByScore(byte @NonNull [] key,
974974
* @since 2.6
975975
* @see <a href="https://redis.io/commands/zdiff">Redis Documentation: ZDIFF</a>
976976
*/
977-
Set<byte[]> zDiff(byte @NonNull [] @Nullable... sets);
977+
Set<byte[]> zDiff(byte @NonNull [] @NonNull ... sets);
978978

979979
/**
980980
* Diff sorted {@code sets}.
@@ -1129,7 +1129,7 @@ Long zInterStore(byte @NonNull [] destKey, @NonNull Aggregate aggregate, @NonNul
11291129
* @since 2.6
11301130
* @see <a href="https://redis.io/commands/zunion">Redis Documentation: ZUNION</a>
11311131
*/
1132-
Set<@NonNull Tuple> zUnionWithScores(Aggregate aggregate, Weights weights, byte @NonNull [] @NonNull... sets);
1132+
Set<@NonNull Tuple> zUnionWithScores( @NonNull Aggregate aggregate, @NonNull Weights weights, byte @NonNull [] @NonNull... sets);
11331133

11341134
/**
11351135
* Union sorted {@code sets}.

0 commit comments

Comments
 (0)