I have a requirement to change properties of a class which is being serialized/deserialized by ObjectMapper.
This is my class.
// Old version
Class A {
String id;
String name;
}
// New version
Class A {
String id;
String firstName;
String secondName;
}
I serialize the object ObjectMapper.writeValueAsString(), send it to a queue to process it later, and when received, deserialize it via ObjectMapper.readValue().
What is the expected behavior of readValue() if the old version of Class A is serialized, but when deserializing - Class A has been updated to the new version.
Will firstName and secondName be null? Or readValue() throw an exception?
And what is the solution here to make the changes smoothly.