Skip to content

Commit 620d889

Browse files
committed
Fix #2091
1 parent a39892c commit 620d889

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

release-notes/CREDITS-2.x

+4
Original file line numberDiff line numberDiff line change
@@ -1110,3 +1110,7 @@ Robin Roos (robinroos@github)
11101110
Mike Gilbode (gilbode@github)
11111111
* Reported #792: Deserialization Not Working Right with Generic Types and Builders
11121112
(2.12.0)
1113+
1114+
Nate Bauernfeind (nbauernfeind@github)
1115+
* Reported #2091: `ReferenceType` does not expose valid containedType
1116+
(2.12.0)

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Project: jackson-databind
88

99
#792: Deserialization Not Working Right with Generic Types and Builders
1010
(reported by Mike G; fix contributed by Ville K)
11+
#2091: `ReferenceType` does not expose valid containedType
12+
(reported by Nate B)
1113
#2683: Explicitly fail (de)serialization of `java.time.*` types in absence of
1214
registered custom (de)serializers
1315
#2707: Improve description included in by `DeserializationContext.handleUnexpectedToken()`

src/main/java/com/fasterxml/jackson/databind/type/TypeFactory.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,8 @@ public JavaType constructSimpleType(Class<?> rawType, Class<?> parameterTarget,
957957
*/
958958
public JavaType constructReferenceType(Class<?> rawType, JavaType referredType)
959959
{
960-
return ReferenceType.construct(rawType, null, // no bindings
960+
return ReferenceType.construct(rawType,
961+
TypeBindings.create(rawType, referredType), // [databind#2091]
961962
null, null, // or super-class, interfaces?
962963
referredType);
963964
}

src/test/java/com/fasterxml/jackson/databind/type/TestJavaType.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,12 @@ public void testConstructReferenceType() throws Exception
280280
assertTrue(t.hasContentType());
281281
assertEquals(Long.class, t.getContentType().getRawClass());
282282

283-
// 26-Mar-2020, tatu: [databind#2019] suggest this should be 1...
284-
// assertEquals(1, t.containedTypeCount());
283+
// 26-Mar-2020, tatu: [databind#2019] made this work
284+
assertEquals(1, t.containedTypeCount());
285+
TypeBindings bindings = t.getBindings();
286+
assertEquals(1, bindings.size());
287+
assertEquals(refdType, bindings.getBoundType(0));
288+
// Should we even verify this or not?
289+
assertEquals("V", bindings.getBoundName(0));
285290
}
286291
}

0 commit comments

Comments
 (0)