spring-projects / spring-data-redis

Provides support to increase developer productivity in Java when using Redis, a key-value store. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-redis/
Apache License 2.0
1.77k stars 1.17k forks source link

ReactiveListOperations left/right pop operations fail with Duration with fractions of second #2975

Open ai91 opened 3 months ago

ai91 commented 3 months ago

According to documentation, leftPop/rightPop methods expect to get Duration parameter ZERO or >= 1 second.

Failure use case: pass Duration with seconds >= 1 second, and nanos > 0. Example:

reactiveRedisTemplate.opsForList().leftPop(key, Duration.ofMillis(10100L));

Fails with exception

java.lang.IllegalArgumentException: Duration must be either zero or greater or equal to 1 second

The issue is caused by wrong implementation of DefaultReactiveListOperations.isZeroOrGreaterOneSecond()

christophstrobl commented 3 months ago

Thank you @ai91 for bringing this up. We'll look into it.

christophstrobl commented 3 months ago

The entire requirement forcing a timeout that is > 1 sec. limits usage of Redis API allowing the timeout to be a

double value specifying the maximum number of seconds to block

We'll need a broader change that also switches the command implementations to use double instead of the current long. The switch from long to double is in since Redis 6. Prior Redis versions are already EOL so I think it's fine to change the current implementation.