File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
src/test/java/com/fasterxml/jackson/failing Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .fasterxml .jackson .failing ;
2
+
3
+ import java .util .List ;
4
+ import java .util .Map ;
5
+
6
+ import com .fasterxml .jackson .databind .*;
7
+
8
+ // [databind#2816]
9
+ public class DeepNestingWithUntyped2816Test extends BaseMapTest
10
+ {
11
+ // 2000 passes, 3000 fails
12
+ private final static int TOO_DEEP_NESTING = 4000 ;
13
+
14
+ private final ObjectMapper MAPPER = newJsonMapper ();
15
+
16
+ public void testWithArray () throws Exception
17
+ {
18
+ final String doc = _nestedDoc (TOO_DEEP_NESTING , "[ " , "] " );
19
+ Object ob = MAPPER .readValue (doc , Object .class );
20
+ assertTrue (ob instanceof List <?>);
21
+ }
22
+
23
+ public void testWithObject () throws Exception
24
+ {
25
+ final String doc = "{" +_nestedDoc (TOO_DEEP_NESTING , "\" x\" :{" , "} " ) + "}" ;
26
+ Object ob = MAPPER .readValue (doc , Object .class );
27
+ assertTrue (ob instanceof Map <?,?>);
28
+ }
29
+
30
+ private String _nestedDoc (int nesting , String open , String close ) {
31
+ StringBuilder sb = new StringBuilder (nesting * (open .length () + close .length ()));
32
+ for (int i = 0 ; i < nesting ; ++i ) {
33
+ sb .append (open );
34
+ if ((i & 31 ) == 0 ) {
35
+ sb .append ("\n " );
36
+ }
37
+ }
38
+ for (int i = 0 ; i < nesting ; ++i ) {
39
+ sb .append (close );
40
+ if ((i & 31 ) == 0 ) {
41
+ sb .append ("\n " );
42
+ }
43
+ }
44
+ return sb .toString ();
45
+ }
46
+ }
You can’t perform that action at this time.
0 commit comments