redis / redis-om-spring

Spring Data Redis extensions for better search, documents models, and more
MIT License
609 stars 94 forks source link

Searching for an expired Document may result in invalid deserialization #483

Closed ClemaX closed 4 months ago

ClemaX commented 4 months ago

Hi, this is a follow-up to #131 .

The fix seems to have mitigated the NPE from within redis-om-spring by substituting the null JSON data with an empty String. This does not seem to be a good solution. It would be much better to treat the Document as inexistent and to return an empty Optional object, because the gson deserialization may result in a uninitialized Object, that causes issues for application developers.

Here is a basic Spring app reproducing this issue on the latest release to this day, v0.9.3: https://github.com/ClemaX/redis-om-spring-ttl-bug-repro

I added a reproduction script that uses docker and the redislabs/redisearch:2.8.8 image.

Steps to reproduce:

git clone https://github.com/ClemaX/redis-om-spring-ttl-bug-repro
cd redis-om-spring-ttl-bug-repro
./reproduce.sh