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
Issue with Kryo5Codec in combination with org.springframework.cache.support.NullValue #5830
Comments
Sorry, Redisson doesn't implement such class |
Yep sry, my bad. I got confused with the class names. JCacheCache is part of the Spring package. |
Can you add the code below into org.redisson.codec.Kryo5Codec#createKryo method and say if it works? if (com.esotericsoftware.kryo.util.Util.isClassAvailable("org.springframework.cache.support.NullValue")) {
kryo.addDefaultSerializer(Class.forName("org.springframework.cache.support.NullValue"), new JavaSerializer());
} |
Yes, it works, thanks. Do you see any trade-offs (like performance) when using the JavaSerializer? My first solution was extending the Kryo5Codec class:
and creating a custom NullValueSerializer:
But your solution has a way smaller footprint than mine. |
Thanks for testing. In your example Spring become a required dependency because of explicit NullValue class definition which I would like to avoid. It would be great if you rewrite it without explicit NullValue definition. |
Hi,
I'm currently having an issue with the Spring Cache implementation in combination with Redisson.
The JCacheCache class provided by Redisson extends
org.springframework.cache.support.AbstractValueAdaptingCache
. In the methodprotected Object fromStoreValue(@Nullable Object storeValue)
of the class AbstractValueAdaptingCache, there is an if condition, that check if the storeValue is equal to NullValue.INSTANCE using ==.This condition evaluated to false in my case, because the instance of storeValue was not the same instance as NullValue.INSTANCE. Reason is the deserialisation, that was done by Kryo. It seems, that Kryo changes the constructor to "public" using reflections and creates a new instance by calling the constructor. It does not call the "readResolve()" method of NullValue class, which would return NullValue.INSTANCE.
Is this a known issue? The only solution I came up with is extending the Kryo5Codec and adding a custom Serializer for NullValue.class. Is there another way to fix this issue?
Best regards
The text was updated successfully, but these errors were encountered: