-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Labels
Milestone
Description
Description
- jdk 11 (not test with jdk 8)
- jackson 2.11.2 / 2.11.3
- primitive field with @Jsonserializer
@JsonSerialize(using = ToStringSerializer.class)
private int primitiveValue;
- if primitiveValue is 10
- if not work with afterburner, will serialize to "10"
- if work with afterburner, will serialize to 10
seems afterburner not handle primitive field @JsonSerialize annotation
Reproduce case
public class AfterBurnerPrimitiveSerializerBug {
public static class Model {
@JsonSerialize(using = ToStringSerializer.class)
private int primitiveValue;
@JsonSerialize(using = ToStringSerializer.class)
private Integer value;
public int getPrimitiveValue() {
return primitiveValue;
}
public Model setPrimitiveValue(int primitiveValue) {
this.primitiveValue = primitiveValue;
return this;
}
public Integer getValue() {
return value;
}
public Model setValue(Integer value) {
this.value = value;
return this;
}
}
public static class AnotherModel extends Model {
}
static Model model = new Model().setPrimitiveValue(10).setValue(10);
static Model anotherModel = new AnotherModel().setPrimitiveValue(10).setValue(10);
static ObjectMapper mapper = new ObjectMapper();
public static void main(String[] args) throws JsonProcessingException {
// will print: {"primitiveValue":"10","value":"10"}
System.out.println(mapper.writeValueAsString(model));
mapper.registerModule(new AfterburnerModule());
// will print: {"primitiveValue":10,"value":"10"}
// primitiveValue lost JsonSerialize feature
System.out.println(mapper.writeValueAsString(anotherModel));
}
}
output
{"primitiveValue":"10","value":"10"}
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.fasterxml.jackson.module.afterburner.util.MyClassLoader (file:/C:/Users/myUser/.m2/repository/com/fasterxml/jackson/module/jackson-module-afterburner/2.11.2/jackson-module-afterburner-2.11.2.jar) to method java.lang.ClassLoader.findLoadedClass(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.fasterxml.jackson.module.afterburner.util.MyClassLoader
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
{"primitiveValue":10,"value":"10"}