-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1650 from slobo-showbie/2.8
Fix #1647: Missing properties from base class when recursive types are involved
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/test/java/com/fasterxml/jackson/databind/type/TestTypeFactoryWithRecursiveTypes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.fasterxml.jackson.databind.type; | ||
|
||
import java.io.IOException; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.BaseMapTest; | ||
import com.fasterxml.jackson.databind.type.TypeFactory; | ||
|
||
|
||
// https://github.com/FasterXML/jackson-databind/issues/1647 | ||
public class TestTypeFactoryWithRecursiveTypes extends BaseMapTest { | ||
|
||
static interface IFace<T> { | ||
} | ||
|
||
static class Base implements IFace<Sub> { | ||
@JsonProperty int base = 1; | ||
} | ||
|
||
static class Sub extends Base { | ||
@JsonProperty int sub = 2; | ||
} | ||
|
||
public void testBasePropertiesIncludedWhenSerializingSubWhenSubTypeLoadedAfterBaseType() throws IOException { | ||
TypeFactory tf = TypeFactory.defaultInstance(); | ||
tf.constructType(Base.class); | ||
tf.constructType(Sub.class); | ||
Sub sub = new Sub(); | ||
String serialized = objectMapper().writeValueAsString(sub); | ||
assertEquals("{\"base\":1,\"sub\":2}", serialized); | ||
} | ||
} |