Reputation: 639
We've identified data corruption during DTO deserialization when there are changes in existing fields/instance variables in a dto
To Reproduce Have a simple dto, lets say employee with following details
public class Employee{
private String name;
private long age;
private String company;
}
Serialize this dto using below code
Output outK3 = new Output(new FileOutputStream("rename.bin"))
kryo.writeObject(out, employee);
outK3.close();
Change the dto
public class Employee{
private String name;
private short xge;
private String company;
}
De-Serialize now using below code
Input input = new Input(new FileInputStream("rename.bin"));
try {
Employee k = kryo.readObject(input, s.getClass());
System.out.println("Kryo 5 Test" + k);
input.close();
Expected Behaviour Since the dto has changes , kryo should either throw an exception or should give the correct data but we are seeing data corruption , example below
Kryo 5 TestEmployee{firstName='Abcde', age=36, company='Kronos'} --- Original Kryo 5 TestEmployee{firstName='Abcde', age=19272, company='ronos'} -- -- After De-Serializing
Environment:
OS: Windows JDK Version: 8 Kryo Version: 5.6.0
Upvotes: 0
Views: 16