File tree 4 files changed +68
-4
lines changed
main/java/com/fasterxml/jackson/databind/type
test/java/com/fasterxml/jackson/databind/type
4 files changed +68
-4
lines changed Original file line number Diff line number Diff line change @@ -629,6 +629,11 @@ Bertrand Renuart (brenuart@github)
629
629
* Reported #1651: `StdDateFormat` fails to parse 'zulu' date when TimeZone other than UTC
630
630
(2.8.9)
631
631
632
+ Kevin Gallardo (newkek@github)
633
+ * Reported #1658: Infinite recursion when deserializing a class extending a Map,
634
+ with a recursive value type
635
+ (2.8.10)
636
+
632
637
Connor Kuhn (ckuhn@github)
633
638
* Contributed #1341: FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
634
639
(2.9.0)
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ Project: jackson-databind
8
8
#1657: `StdDateFormat` deserializes dates with no tz/offset as UTC instead of
9
9
configured timezone
10
10
(reported by Bertrand R)
11
+ #1658: Infinite recursion when deserializing a class extending a Map,
12
+ with a recursive value type
13
+ (reported by Kevin G)
11
14
12
15
2.8.9 (12-Jun-2017)
13
16
Original file line number Diff line number Diff line change @@ -111,11 +111,22 @@ public String toString() {
111
111
public boolean equals (Object o ) {
112
112
if (o == this ) return true ;
113
113
if (o == null ) return false ;
114
- // Do NOT ever match unresolved references
115
- if (_referencedType == null ) {
114
+ if (o .getClass () == getClass ()) {
115
+ // 16-Jun-2017, tatu: as per [databind#1658], can not do recursive call since
116
+ // there is likely to be a cycle...
117
+
118
+ // but... true or false?
116
119
return false ;
120
+
121
+ /*
122
+ // Do NOT ever match unresolved references
123
+ if (_referencedType == null) {
124
+ return false;
125
+ }
126
+ return (o.getClass() == getClass()
127
+ && _referencedType.equals(((ResolvedRecursiveType) o).getSelfReferencedType()));
128
+ */
117
129
}
118
- return (o .getClass () == getClass ()
119
- && _referencedType .equals (((ResolvedRecursiveType ) o ).getSelfReferencedType ()));
130
+ return false ;
120
131
}
121
132
}
Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .databind .type ;
2
+
3
+ import java .util .*;
4
+
5
+ import com .fasterxml .jackson .annotation .JsonTypeInfo ;
6
+ import com .fasterxml .jackson .databind .*;
7
+ import com .fasterxml .jackson .databind .jsontype .TypeResolverBuilder ;
8
+ import com .fasterxml .jackson .databind .jsontype .impl .StdTypeResolverBuilder ;
9
+
10
+ public class RecursiveType1658Test extends BaseMapTest
11
+ {
12
+ @ SuppressWarnings ("serial" )
13
+ static class Tree <T > extends HashMap <T , Tree <T >> // implements Serializable
14
+ {
15
+ public Tree () { }
16
+
17
+ public Tree (List <T > children ) {
18
+ this ();
19
+ for (final T t : children ) {
20
+ this .put (t , new Tree <T >());
21
+ }
22
+ }
23
+
24
+ public List <Tree <T >> getLeafTrees () {
25
+ return null ;
26
+ }
27
+ }
28
+
29
+ public void testRecursive1658 () throws Exception
30
+ {
31
+ Tree <String > t = new Tree <String >(Arrays .asList ("hello" , "world" ));
32
+ ObjectMapper mapper = new ObjectMapper ();
33
+
34
+ final TypeResolverBuilder <?> typer = new StdTypeResolverBuilder ()
35
+ .init (JsonTypeInfo .Id .CLASS , null )
36
+ .inclusion (JsonTypeInfo .As .PROPERTY );
37
+ mapper .setDefaultTyping (typer );
38
+
39
+ String res = mapper .writeValueAsString (t );
40
+
41
+ Tree <?> tRead = mapper .readValue (res , Tree .class );
42
+
43
+ assertNotNull (tRead );
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments