Skip to content

slobo-showbie/jackson-recursive-type-bug

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This jackson bug prevents a sub class' properties from being serialized when

  1. some properties are in the base class,
  2. the base class has an interface that directly or indirectly references the sub class, and
  3. the base class's type is constructed first from the TypeFactory.

Running

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 !!!

Running (Alternate)

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}

About

Demonstrates a Jackson serialization bug with recursive types.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages