Skip to content

Commit

Permalink
test case to illustrate jackson-543, generic widening serialization bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ahgittin committed Sep 13, 2014
1 parent 2dde645 commit c9d89b4
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ static class ContainerWithField<T extends Animal> {
public ContainerWithField(T a) { animal = a; }
}

static class ContainerWithTwoAnimals<U extends Animal,V extends Animal> extends ContainerWithField<U> {
public V otherAnimal;

public ContainerWithTwoAnimals(U a1, V a2) {
super(a1);
otherAnimal = a2;
}
}

static class WrappedContainerWithField {
public ContainerWithField<?> animalContainer;
}

// Beans for [JACKSON-387], [JACKSON-430]

@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@classAttr1")
Expand Down Expand Up @@ -201,4 +214,13 @@ public void testJackson430() throws Exception
assertNotNull(mc2.params);
assertEquals(1, mc2.params.size());
}

public void testValueWithMoreGenericParameters() throws Exception
{
WrappedContainerWithField wrappedContainerWithField = new WrappedContainerWithField();
wrappedContainerWithField.animalContainer = new ContainerWithTwoAnimals<Dog,Dog>(new Dog("d1",1), new Dog("d2",2));
new ObjectMapper().writeValueAsString(wrappedContainerWithField);
// line above throws exception due to JACKSON-543
}

}

0 comments on commit c9d89b4

Please sign in to comment.