Closed spring-projects-issues closed 8 years ago
Mark Paluch commented
We need to take also other operations into account. Incrementing absent keys leads in Redis to 1
127.0.0.1:6479> del key
(integer) 0
127.0.0.1:6479> incr key
(integer) 1
which seems ok to me to return 1
. Decrementing works similar. The only operation which is not guarded is getAndSet
. At this time the new value is already set and the command returns null
Walt Davidson opened DATAREDIS-469 and commented
RedisAtomicLong throws a null pointer on get, if the key has been removed/expired from the underlying Redis store. It looks like an autoboxing issue, when jedis returns null as the value for the key.
The code is quite clear. operations.get(key); returns null, and java unboxing to an int throws a NullPointer .
Stacktrace
Can be reproduced with a simple test
Affects: 1.6.2 (Gosling SR2)
Referenced from: pull request https://github.com/spring-projects/spring-data-redis/pull/182
Backported to: 1.7.2 (Hopper SR2), 1.6.5 (Gosling SR5)