New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NPE when querying an expired (TTL) JSON document #131
Comments
@Paure42 thank you. Can you also post the repository code if any? |
public interface XXXXX extends RedisDocumentRepository<XXXXX, String> { |
and one more question, is this with |
Both of them |
My guess is the TTL expires the key, but the key is still in the index at the time of query, but then it NPEs when trying to retrieve the payload of the object. |
Yes I think too |
@Paure42 I still can't seem to be able to replicate it. I tried a test like:
But it passes without any code changes. Any ideas that will make it closer to your impl? Entity model:
and repo:
|
FYI, I did add a guard for NPE in the RediSearchQuery class which should fix the issue even if I can reproduce. |
@Paure42 if you pull |
Thank you for your work, but the NPE is still there : at com.redis.om.spring.repository.query.RediSearchQuery.executeQuery(RediSearchQuery.java:362) Your impl is close to mine, I don't know why you can't reproduce it. |
Could you create a self-contained reproducer project? |
Also, try to clear your Maven cache since I pushed that SNAPSHOT a few timed |
My maven cache was cleaned up when I tried I will try to create a self-contained reproducer project |
I think I found something interesting. Here is my class:
My repository :
And my code:
This cause NPE :
However if I remove Seems to be some case of race condition. |
There is a non-negligible time between an object being saved and the index getting updated. I added an extra check for null on the root of the JSON document returned by the engine. I just pushed a new version of the SNAPSHOT. Clear your cache again and give it a try please. |
Works for me ! |
Thanks, @Paure42! Keep them coming! |
I think this a bug related to the TimeToLive but I may be wrong, when a query looks for an element of a key, in my case a hash compute with some data, that has been erased by the time to live, there is a null pointer exception thrown:
java.lang.NullPointerException
at com.redis.om.spring.repository.query.RediSearchQuery.executeQuery(RediSearchQuery.java:344)
at com.redis.om.spring.repository.query.RediSearchQuery.execute(RediSearchQuery.java:267)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.doInvoke(RepositoryMethodInvoker.java:137)
at org.springframework.data.repository.core.support.RepositoryMethodInvoker.invoke(RepositoryMethodInvoker.java:121)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.doInvoke(QueryExecutorMethodInterceptor.java:159)
at org.springframework.data.repository.core.support.QueryExecutorMethodInterceptor.invoke(QueryExecutorMethodInterceptor.java:138)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
at com.sun.proxy.$Proxy174.findByHash(Unknown Source)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215)
at com.sun.proxy.$Proxy174.findByHash(Unknown Source)
Here is the class:
@document(value = "XXXXXX", timeToLive = 10 * 60)
@DaTa
public class XXXXXX {
@id
private String id;
@indexed
@nonnull
private String hash;
}
The text was updated successfully, but these errors were encountered: