Skip to content

Commit

Permalink
Add a (failing) test for #3582
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Aug 24, 2022
1 parent aac05b7 commit 35de19e
Showing 1 changed file with 41 additions and 0 deletions.
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();
}

}

0 comments on commit 35de19e

Please sign in to comment.