At Android both FstCodec and MarshallingCodec don't run
See original GitHub issueUsing this simple code at android (java):
`
private RList<MyObject> connect(String address) {
Config config = new Config();
config.useSingleServer().setAddress(address);
RedissonClient client = Redisson.create(config);
return client.getList("Section::Unit"); }
`
I get this IllegalStateException:
Caused by: java.lang.IllegalStateException: java.lang.reflect.InvocationTargetException at org.redisson.command.RedisExecutor.getCodec(RedisExecutor.java:692) at org.redisson.command.RedisExecutor.execute(RedisExecutor.java:113) at org.redisson.command.CommandAsyncService.async(CommandAsyncService.java:612) at org.redisson.command.CommandAsyncService.readAsync(CommandAsyncService.java:369) at org.redisson.RedissonList.getAsync(RedissonList.java:296) at org.redisson.RedissonList.getValue(RedissonList.java:325) at org.redisson.RedissonList$1.getValue(RedissonList.java:500)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Class.isPrimitive()' on a null object reference at org.objenesis.ObjenesisBase.getInstantiatorOf(ObjenesisBase.java:86) at org.nustaq.serialization.FSTObjenesisInstantiator.<init>(FSTObjenesisInstantiator.java:38) at org.nustaq.serialization.FSTConfiguration$4.getInstantiator(FSTConfiguration.java:403) at org.redisson.codec.FstCodec.copy(FstCodec.java:200)
Looking inside code I found that this function (file FstCodec.java):
` package org.redisson.codec;
public FstCodec(ClassLoader classLoader, FstCodec codec) {
this(copy(classLoader, codec));
}
` … call private copy function and this one call def.setInstantiator(codec.config.getInstantiator(null)).
The problem is, at android, FstCodec call this function: ` package org.nustaq.serialization;
protected static FSTConfiguration createAndroidDefaultConfiguration(ConcurrentHashMap<FieldKey,FSTClazzInfo.FSTFieldInfo> shared) {
final Objenesis genesis = new ObjenesisStd();
FSTConfiguration conf = new FSTConfiguration(shared) {
@Override
public FSTClassInstantiator getInstantiator(Class clazz) {
return new FSTObjenesisInstantiator(genesis,clazz);
}
};
` … that override default getInstantiator(class class2instantiate) that must not receive parameter as null.
I’m using: implementation ‘de.ruedigermoeller:fst:2.57’ implementation ‘org.redisson:redisson:3.12.5’ at gradle dependency and redis 6.0.3 version running at docker. android compileSdkVersion 29 (android 10.0 Q)
Thanks for this incredible program, I holpe that this help you to improve it.
hipolito
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Thank you by your attention and help! Sorry by the long time to answer… I’ve run tests with both redisson versions 3.12.5 and 3.13.0 and found the same error. At both MarshallingCodec doesn’t run at android.
I’d like help you fix that and find the error location at android. Let me show you:
Running this simple code:
I got this error:
The problem here is… To allocate MarshallingCodec we have this constructor: Called with protocol = ‘RIVER’ and configuration = ‘null’ [that’s OK!]
Marshalling.getProvidedMarshallerFactory(‘river’) call this function [that’s OK!]:
Even I set or don’t SecurityManager I got the same error, so let’s try with getSecurityManager() return ‘null’ this function try set registry using SerializableClassRegistry.getInstance() but,
now you can see, that inside the class SerializableClassRegistry the static final var SerializablePermission PERMISSION is always initialized with new SerializablePermission(“allowSerializationReflection”) before the function getInstance() is called, even when getSecurityManager() return null! [that’s not OK!!!]
That’s the problem. At android, SerializablePermission is not defined, as you can see here!
So the RiverProviderDescriptor could not be instantiated.
To these tests I use:
at gradle dependency
and redis 6.0.3 version running at docker android compileSdkVersion 29 (android 10.0 Q)
If that make sense for you I have some suggestions about how to fix error at redisson using coded FstCodec, but both class SerializableClassRegistry (package org.jboss.marshalling.reflect) and SerializablePermission (package java.io) are set final so I can’t see how to fix this inside redisson.
Cheers, hipolito
Thanks for your feedback! I’ll note Kyro5Codec and SerializationCodec codecs as Android compatible on https://github.com/redisson/redisson/wiki/4.-data-serialization page. JsonJacksonCodec is also compatible.