-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aac05b7
commit 35de19e
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
...test/java/com/fasterxml/jackson/databind/deser/dos/DeepArrayWrappingForDeser3582Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.fasterxml.jackson.databind.deser.dos; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
|
||
public class DeepArrayWrappingForDeser3582Test extends BaseMapTest | ||
{ | ||
// 23-Aug-2022, tatu: Before fix, fails with 5000 | ||
// (but passes with 2000) | ||
// private final static int TOO_DEEP_NESTING = 4999; | ||
private final static int TOO_DEEP_NESTING = 1999; | ||
|
||
private final ObjectMapper MAPPER = jsonMapperBuilder() | ||
.enable(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) | ||
.build(); | ||
|
||
public void testArrayWrapping() throws Exception | ||
{ | ||
final String doc = _nestedDoc(TOO_DEEP_NESTING, "[ ", "] ", "{}"); | ||
Point p = MAPPER.readValue(doc, Point.class); | ||
assertNotNull(p); | ||
} | ||
|
||
private String _nestedDoc(int nesting, String open, String close, String content) { | ||
StringBuilder sb = new StringBuilder(nesting * (open.length() + close.length())); | ||
for (int i = 0; i < nesting; ++i) { | ||
sb.append(open); | ||
if ((i & 31) == 0) { | ||
sb.append("\n"); | ||
} | ||
} | ||
sb.append("\n").append(content).append("\n"); | ||
for (int i = 0; i < nesting; ++i) { | ||
sb.append(close); | ||
if ((i & 31) == 0) { | ||
sb.append("\n"); | ||
} | ||
} | ||
return sb.toString(); | ||
} | ||
|
||
} |