RuedigerMoeller / fast-serialization

FST: fast java serialization drop in-replacement
Apache License 2.0
1.59k stars 247 forks source link

Deserialization Error in case of Collections #240

Open ritvik88 opened 6 years ago

ritvik88 commented 6 years ago

Hi Ruediger,

How are you !!

I am getting the same issue again, while deserializing arraylist object. I am using FST 2.40 version. Please see below testcase,

public class EntitySuperClass implements Serializable{ private List tags; }

public class Entity implements Serializable{ private String name; private int id; }

If i add new instance variable to Entity class(Forward compatibility),

public class Entity implements Serializable{ private String name; private int id; // New instance variable private String address; }

After deserialzing EntitySuperClass object, I am getting below exception : class java.util.ArrayList deserialization problem java.io.IOException: java.lang.RuntimeException:

To handle this issue , i have added version check in super class like,

public class EntitySuperClass implements Serializable{ @org.nustaq.serialization.annotations.Version(2) private List tags;

}

public class Entity implements Serializable{

private String name; private int id; @org.nustaq.serialization.annotations.Version(2) private String address

}

I am getting below exception

FSTSerializer : Deserialization error: java.lang.RuntimeException: read version tag -1 fieldInfo has 2 Deserialization error: java.lang.RuntimeException: read version tag 1 fieldInfo has 2

Please check, If u can help me out here.

Thanks

RuedigerMoeller commented 6 years ago

versioning support is shaky (severe logical restrictions I cannot workaround). Will have a look into as i find time

ritvik88 commented 5 years ago

Hello there, org.nustaq.serialization.annotations.Version(), this also doesnot support backward compatibility.Is there any other work around.