spring-data-redis icon indicating copy to clipboard operation
spring-data-redis copied to clipboard

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

Open ai91 opened this issue 1 year ago • 2 comments

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()

ai91 avatar Aug 21 '24 16:08 ai91

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

christophstrobl avatar Aug 26 '24 10:08 christophstrobl

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.

christophstrobl avatar Aug 26 '24 11:08 christophstrobl