Skip to content

Commit 75fcb0e

Browse files
DATAREDIS-611 - Update Javadoc and remove superfluous negativity limitations.
Original Pull Request: spring-projects#501
1 parent 31d4730 commit 75fcb0e

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

src/main/java/org/springframework/data/redis/core/BoundKeyOperations.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,15 @@ public interface BoundKeyOperations<K> {
6464
* Sets the key time-to-live/expiration.
6565
*
6666
* @param timeout must not be {@literal null}.
67-
* @return true if expiration was set, false otherwise. {@literal null} when used in pipeline / transaction.
67+
* @return {@literal true} if expiration was set, {@literal false} otherwise. {@literal null} when used in pipeline /
68+
* transaction.
69+
* @throws IllegalArgumentException if the timeout is {@literal null}.
6870
* @since 2.3
6971
*/
7072
@Nullable
7173
default Boolean expire(Duration timeout) {
7274

7375
Assert.notNull(timeout, "Timeout must not be null");
74-
Assert.isTrue(!timeout.isNegative(), "Timeout must not be negative");
7576

7677
return expire(timeout.toMillis(), TimeUnit.MILLISECONDS);
7778
}
@@ -98,14 +99,16 @@ default Boolean expire(Duration timeout) {
9899
/**
99100
* Sets the key time-to-live/expiration.
100101
*
101-
* @param time expiration time.
102-
* @return true if expiration was set, false otherwise. {@literal null} when used in pipeline / transaction.
102+
* @param expireAt expiration time.
103+
* @return {@literal true} if expiration was set, {@literal false} otherwise. {@literal null} when used in pipeline /
104+
* transaction.
105+
* @throws IllegalArgumentException if the instant is {@literal null} or too large to represent as a {@code Date}.
103106
* @since 2.3
104107
*/
105108
@Nullable
106109
default Boolean expireAt(Instant expireAt) {
107110

108-
Assert.notNull(expireAt, "Timestamp must not be null");
111+
Assert.notNull(expireAt, "ExpireAt must not be null");
109112

110113
return expireAt(Date.from(expireAt));
111114
}

src/main/java/org/springframework/data/redis/core/BoundListOperations.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ public interface BoundListOperations<K, V> extends BoundKeyOperations<K> {
196196
*
197197
* @param timeout must not be {@literal null}.
198198
* @return {@literal null} when timeout reached or used in pipeline / transaction.
199+
* @throws IllegalArgumentException if the timeout is {@literal null} or negative.
199200
* @since 2.3
200201
* @see <a href="https://redis.io/commands/blpop">Redis Documentation: BLPOP</a>
201202
*/
@@ -235,6 +236,7 @@ default V leftPop(Duration timeout) {
235236
*
236237
* @param timeout must not be {@literal null}.
237238
* @return {@literal null} when timeout reached or used in pipeline / transaction.
239+
* @throws IllegalArgumentException if the timeout is {@literal null} or negative.
238240
* @since 2.3
239241
* @see <a href="https://redis.io/commands/brpop">Redis Documentation: BRPOP</a>
240242
*/

src/main/java/org/springframework/data/redis/core/ListOperations.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public interface ListOperations<K, V> {
243243
* @param key must not be {@literal null}.
244244
* @param timeout must not be {@literal null}.
245245
* @return can be {@literal null}.
246+
* @throws IllegalArgumentException if the timeout is {@literal null} or negative.
246247
* @since 2.3
247248
* @see <a href="https://redis.io/commands/blpop">Redis Documentation: BLPOP</a>
248249
*/
@@ -330,6 +331,7 @@ default V rightPop(K key, Duration timeout) {
330331
* @param destinationKey must not be {@literal null}.
331332
* @param timeout must not be {@literal null}.
332333
* @return can be {@literal null}.
334+
* @throws IllegalArgumentException if the timeout is {@literal null} or negative.
333335
* @since 2.3
334336
* @see <a href="https://redis.io/commands/brpoplpush">Redis Documentation: BRPOPLPUSH</a>
335337
*/

src/main/java/org/springframework/data/redis/core/RedisOperations.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,13 +289,13 @@ <T> T execute(RedisScript<T> script, RedisSerializer<?> argsSerializer, RedisSer
289289
* @param key must not be {@literal null}.
290290
* @param timeout must not be {@literal null}.
291291
* @return {@literal null} when used in pipeline / transaction.
292+
* @throws IllegalArgumentException if the timeout is {@literal null}.
292293
* @since 2.3
293294
*/
294295
@Nullable
295296
default Boolean expire(K key, Duration timeout) {
296297

297298
Assert.notNull(timeout, "Timeout must not be null");
298-
Assert.isTrue(!timeout.isNegative(), "Timeout must not be negative");
299299

300300
return TimeoutUtils.hasMillis(timeout) ? expire(key, timeout.toMillis(), TimeUnit.MILLISECONDS)
301301
: expire(key, timeout.getSeconds(), TimeUnit.SECONDS);
@@ -317,6 +317,7 @@ default Boolean expire(K key, Duration timeout) {
317317
* @param key must not be {@literal null}.
318318
* @param expireAt must not be {@literal null}.
319319
* @return {@literal null} when used in pipeline / transaction.
320+
* @throws IllegalArgumentException if the instant is {@literal null} or too large to represent as a {@code Date}.
320321
* @since 2.3
321322
*/
322323
@Nullable

src/test/java/org/springframework/data/redis/core/DefaultListOperationsTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,9 @@ public void testLeftPushAll() {
131131
assertThat(listOps.range(key, 0, -1)).contains(v3, v2, v1);
132132
}
133133

134-
@Test
134+
@Test // DATAREDIS-611
135135
public void testLeftPopDuration() {
136+
136137
// 1 ms timeout gets upgraded to 1 sec timeout at the moment
137138
assumeTrue(RedisTestProfileValueSource.matches("runLongTests", "true"));
138139
assumeTrue(valueFactory instanceof StringObjectFactory);
@@ -146,8 +147,9 @@ public void testLeftPopDuration() {
146147
assertThat(listOps.leftPop(key, Duration.ofSeconds(1))).isEqualTo(v1);
147148
}
148149

149-
@Test
150+
@Test // DATAREDIS-611
150151
public void testRightPopDuration() {
152+
151153
// 1 ms timeout gets upgraded to 1 sec timeout at the moment
152154
assumeTrue(RedisTestProfileValueSource.matches("runLongTests", "true"));
153155
assumeTrue(valueFactory instanceof StringObjectFactory);

0 commit comments

Comments
 (0)