Deserialization after adding new field in Serializable class doesn't throw any exception.
I am using FST to serialize and deserialize java objects in/out of redis. FST version used: 1.63(issue producible even in 2.47) Below is the code used:
static FSTConfiguration conf = FSTConfiguration.createDefaultConfiguration();
for serialize: byte[] bytes = conf.asByteArray((Serializable) object);
Deserialize: conf.asObject(uncompressedBytes);
Deserialization after adding new field in Serializable class doesn't throw any exception instead it deserialize the byte[] with incorrect data.
I serialized below object with values mentioned in comment: public class TestPojo implements Serializable {
private static final long serialVersionUID = 6414799007524074403L; int id; //11 String name; // Bikas String address; // null
//getter and setters }
To test our production case, before deserializing the object I removed "address" field. To my surprise it doesn't throw any exception instead it deserialze the TestPojo object successfully with incorrect value: id=11 and name=null
fst does not make any attempts on versioning (see readme front page), you need to come up with a manual solution at this point in time :)
Any examples how to handle it?
Create a new Subclass which then contains the new field for backward compatibility. The binary stream cannot recover from such changes.