EsotericSoftware / EsotericSoftware/kryo

serialize/deserialize field with default value mistake

Open
#851 6 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
HTML
Stars
6.5k
Forks
841
Avg merge
39m
Merged PRs (30d)
4

Description

**Describe the bug**
```java
public static void main(String[] args) {

A param = new A();
param.setI(null);
System.out.println(param);
// console print "null"

Kryo kryo = new Kryo();
kryo.setRegistrationRequired(false);

kryo.setDefaultSerializer(CompatibleFieldSerializer.class);

Output output = getOutput();
kryo.writeClassAndObject(output, param);

param = (A) kryo.readClassAndObject(new Input(output.toBytes()));

System.out.println(param);
// console print 10
}

public static class A {
private Integer i = 10;

public Integer getI() {
return i;
}

public void setI(Integer i) {
this.i = i;
}

@Override
public String toString() {
return String.valueOf(i);
}

}
```

**Environment:**
- Kryo Version: 5.2.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.