Skip to content
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

enables references to the same object and cyclic graphs to be serialized #5743

Open
yarivMobitti opened this issue Apr 1, 2024 · 0 comments
Labels

Comments

@yarivMobitti
Copy link

I'm trying to save a recursive object in Redis. For example:

public Test(){ Test test; }
I noticed that the codec implementation is Kryo5Codec, which is set with kryo.setReferences(false); when initializing the Kryo object:

protected Kryo createKryo(ClassLoader classLoader) { Kryo kryo = new Kryo(); if (classLoader != null) { kryo.setClassLoader(classLoader); } kryo.setInstantiatorStrategy(new SimpleInstantiatorStrategy()); kryo.setRegistrationRequired(false); kryo.setReferences(false); kryo.addDefaultSerializer(Throwable.class, new JavaSerializer()); kryo.addDefaultSerializer(UUID.class, new DefaultSerializers.UUIDSerializer()); kryo.addDefaultSerializer(URI.class, new DefaultSerializers.URISerializer()); kryo.addDefaultSerializer(Pattern.class, new DefaultSerializers.PatternSerializer()); return kryo; }

To solve this, I overrode it like so:

`public class CustomKryoCodec extends Kryo5Codec {

@Override
protected Kryo createKryo(ClassLoader classLoader) {
	Kryo kryo = super.createKryo(classLoader);
	kryo.setReferences(true);
	return kryo;
}

}`

and set the Redisson config with:

config.setCodec(new CustomKryoCodec());

Is there native support in Redisson for working with recursive objects?

Redisson version: 3.23.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant