Caused by: com.esotericsoftware.kryo.KryoException: Class cannot be created (missing no-arg constructor): java.util.Arrays$ArrayList
Serialization trace:
keyHashes (org.redisson.RedissonLocalCachedMap$LocalCachedMapInvalidate)
at com.esotericsoftware.kryo.Kryo$DefaultInstantiatorStrategy.newInstantiatorOf(Kryo.java:1310) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.Kryo.newInstantiator(Kryo.java:1127) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.Kryo.newInstance(Kryo.java:1136) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.create(CollectionSerializer.java:107) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:111) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.CollectionSerializer.read(CollectionSerializer.java:40) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.Kryo.readObject(Kryo.java:734) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.ObjectField.read(ObjectField.java:125) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.serializers.FieldSerializer.read(FieldSerializer.java:540) ~[kryo-4.0.0.jar:na]
at com.esotericsoftware.kryo.Kryo.readClassAndObject(Kryo.java:816) ~[kryo-4.0.0.jar:na]
at org.redisson.codec.KryoCodec$1.decode(KryoCodec.java:112) ~[redisson-3.4.2.jar:na]
at org.redisson.client.protocol.pubsub.PubSubMessageDecoder.decode(PubSubMessageDecoder.java:38) ~[redisson-3.4.2.jar:na]
at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:283) ~[redisson-3.4.2.jar:na]
at org.redisson.client.handler.CommandDecoder.decodeList(CommandDecoder.java:313) ~[redisson-3.4.2.jar:na]
at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:302) ~[redisson-3.4.2.jar:na]
at org.redisson.client.handler.CommandDecoder.decode(CommandDecoder.java:120) ~[redisson-3.4.2.jar:na]
at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:367) ~[netty-codec-4.1.10.Final.jar:4.1.10.Final]
... 20 common frames omitted
Source code about org.redisson.RedissonLocalCachedMap$LocalCachedMapInvalidate:
```
public static class LocalCachedMapInvalidate implements Serializable {
private byte[] excludedId;
private List<byte[]> keyHashes;
public LocalCachedMapInvalidate() {
}
public LocalCachedMapInvalidate(byte[] excludedId, byte[]... keyHash) {
super();
this.keyHashes = Arrays.asList(keyHash);
this.excludedId = excludedId;
}
public byte[] getExcludedId() {
return excludedId;
}
public Collection<byte[]> getKeyHashes() {
return keyHashes;
}
}
```
Thanks for report!
Version is 3.4.2
kryo version is 4.0.0
There are a few solutions, either changing Arrays.asList(keyHash); to a normal arraylist or by registering custom serializers to support "immutable" collections..
https://github.com/magro/kryo-serializers
<dependency>
<groupId>de.javakaffee</groupId>
<artifactId>kryo-serializers</artifactId>
<version>0.41</version>
</dependency>
kryo.register( Arrays.asList( "" ).getClass(), new ArraysAsListSerializer() );
kryo.register( Collections.EMPTY_LIST.getClass(), new CollectionsEmptyListSerializer() );
kryo.register( Collections.EMPTY_MAP.getClass(), new CollectionsEmptyMapSerializer() );
kryo.register( Collections.EMPTY_SET.getClass(), new CollectionsEmptySetSerializer() );
kryo.register( Collections.singletonList( "" ).getClass(), new CollectionsSingletonListSerializer() );
kryo.register( Collections.singleton( "" ).getClass(), new CollectionsSingletonSetSerializer() );
kryo.register( Collections.singletonMap( "", "" ).getClass(), new CollectionsSingletonMapSerializer() );
kryo.register( GregorianCalendar.class, new GregorianCalendarSerializer() );
kryo.register( InvocationHandler.class, new JdkProxySerializer() );
UnmodifiableCollectionsSerializer.registerSerializers( kryo );
SynchronizedCollectionsSerializer.registerSerializers( kryo );
@johnou I always wondered why they didn't register all these serializers by default.
Fixed
Most helpful comment
Fixed