liqipeng opened a new issue, #1880:
URL: https://github.com/apache/fury/issues/1880
### Question
Step1: Serialize object **without** ```private Integer age;```
```
public class Demo1 {
@Data
public static class Class1 {
private String name;
// private Integer age;
}
public static void main(String[] args) throws IOException {
Fury fury = Fury.builder()
.withLanguage(Language.JAVA)
.withRefTracking(true)
.requireClassRegistration(false)
.withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
.build();
File file = new File("test.dat");
Class1 obj1 = new Class1();
obj1.setName("Tom");
byte[] data1 = fury.serialize(obj1);
FileUtils.writeByteArrayToFile(file, data1);
}
}
```
Step2: Derialize object **with** ```private Integer age;```
```
public class Demo1 {
@Data
public static class Class1 {
private String name;
private Integer age;
}
public static void main(String[] args) throws IOException {
Fury fury = Fury.builder()
.withLanguage(Language.JAVA)
.withRefTracking(true)
.requireClassRegistration(false)
.withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
.build();
File file = new File("test.dat");
byte[] data2 = FileUtils.readFileToByteArray(file);
Class1 obj2 = (Class1) fury.deserialize(data2);
Objects.equals("Tom", obj2.name);
}
}
```
Throw exception:
```
Exception in thread "main"
org.apache.fury.exception.DeserializationException: Deserialize failed, read
objects are: [Demo1.Class1(name=null, age=6)]
at
org.apache.fury.util.ExceptionUtils.handleReadFailed(ExceptionUtils.java:63)
at org.apache.fury.Fury.deserialize(Fury.java:796)
at org.apache.fury.Fury.deserialize(Fury.java:714)
at com.example.Demo1.main(Demo1.java:33)
Caused by: java.lang.IllegalArgumentException: 2
at
org.apache.fury.util.Preconditions.checkArgument(Preconditions.java:52)
at
org.apache.fury.serializer.StringSerializer.readUtf8(StringSerializer.java:252)
at
org.apache.fury.serializer.StringSerializer.readCompressedCharsString(StringSerializer.java:247)
at
com.example.Demo1_Class1FuryRefCodec_0.read(Demo1_Class1FuryRefCodec_0.java:69)
at org.apache.fury.Fury.readDataInternal(Fury.java:958)
at org.apache.fury.Fury.readRef(Fury.java:860)
at org.apache.fury.Fury.deserialize(Fury.java:792)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]