Skip to content

Commit 0b449ff

Browse files
committed
further attempts to make test for #1125, still no luck.
1 parent 5193a6a commit 0b449ff

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/main/java/com/fasterxml/jackson/databind/jsontype/impl/StdSubtypeResolver.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ protected void _collectAndResolveByTypeId(AnnotatedClass annotatedType, NamedTyp
264264
if (namedType.hasName()) {
265265
byName.put(namedType.getName(), namedType);
266266
}
267-
267+
268268
// only check subtypes if this type hadn't yet been handled
269269
if (typesHandled.add(namedType.getType())) {
270270
Collection<NamedType> st = ai.findSubtypes(annotatedType);

src/test/java/com/fasterxml/jackson/databind/jsontype/TestPolymorphicWithDefaultImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static class DefaultWithVoidAsDefault { }
6464
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
6565
abstract static class MysteryPolymorphic { }
6666

67-
// [Databind#511] types
67+
// [databind#511] types
6868

6969
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME,
7070
include = JsonTypeInfo.As.WRAPPER_OBJECT)

src/test/java/com/fasterxml/jackson/databind/jsontype/TestSubtypes.java

+41
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,35 @@ static class AtomicWrapper {
9292
public AtomicWrapper() { }
9393
public AtomicWrapper(int x) { value = new ImplX(x); }
9494
}
95+
96+
// [databind#1125]
97+
98+
static class Issue1125Wrapper {
99+
public Base1125 value;
100+
101+
public Issue1125Wrapper() { }
102+
public Issue1125Wrapper(Base1125 v) { value = v; }
103+
}
95104

105+
@JsonTypeInfo(use=JsonTypeInfo.Id.NAME)
106+
@JsonSubTypes({ @JsonSubTypes.Type(Interm1125.class) })
107+
static class Base1125 {
108+
public int a;
109+
}
110+
111+
@JsonSubTypes({ @JsonSubTypes.Type(value=Impl1125.class, name="impl") })
112+
static class Interm1125 extends Base1125 { }
113+
114+
static class Impl1125 extends Interm1125 {
115+
public int b;
116+
117+
public Impl1125() { }
118+
public Impl1125(int a0, int b0) {
119+
a = a0;
120+
b = b0;
121+
}
122+
}
123+
96124
/*
97125
/**********************************************************
98126
/* Unit tests
@@ -257,4 +285,17 @@ public void testViaAtomic() throws Exception {
257285
assertEquals(ImplX.class, output.value.getClass());
258286
assertEquals(3, ((ImplX) output.value).x);
259287
}
288+
289+
// [databind#1125]: properties from base class too
290+
public void testIssue1125() throws Exception
291+
{
292+
String json = MAPPER.writeValueAsString(new Issue1125Wrapper(new Impl1125(1, 2)));
293+
294+
Issue1125Wrapper result = MAPPER.readValue(json, Issue1125Wrapper.class);
295+
assertNotNull(result.value);
296+
assertEquals(Impl1125.class, result.value.getClass());
297+
Impl1125 impl = (Impl1125) result.value;
298+
assertEquals(1, impl.a);
299+
assertEquals(2, impl.b);
300+
}
260301
}

0 commit comments

Comments
 (0)