This jackson bug prevents a sub class' properties from being serialized when
- some properties are in the base class,
- the base class has an interface that directly or indirectly references the sub class, and
- the base class's type is constructed first from the TypeFactory.
You can using the maven exec plugin:
mvn compile exec:java -Dexec.mainClass="Bug"
Output:
baseJT = [simple type, class Bug$Base]
subJT = [simple type, class Bug$Sub]
subJT.getSuperClass() = [recursive type; Bug$Base
json(sub) = {"sub":2} // missing "base":1 !!!
Runs by passing the sub class first into the TypeFactory (bug is not triggered)
mvn compile exec:java -Dexec.mainClass="Bug" -Dexec.args="sub"
Output:
baseJT = [simple type, class Bug$Base]
subJT = [simple type, class Bug$Sub]
subJT.getSuperClass() = [simple type, class Bug$Base]
json(sub) = {"base":1,"sub":2}