From 1ed33dea495a9501e5a4979dc13447831a318107 Mon Sep 17 00:00:00 2001 From: joohyukkim Date: Sun, 14 May 2023 15:13:09 +0900 Subject: [PATCH 1/5] Update StreamReadStringConstraintsTest.java --- .../databind/deser/dos/StreamReadStringConstraintsTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java index ebc572f6ed..c13df305b0 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java @@ -32,7 +32,7 @@ void setString(String string) { /********************************************************************** */ - private final static int TOO_LONG_STRING_VALUE = 20_100_000; + private final static int TOO_LONG_STRING_VALUE = StreamReadConstraints.DEFAULT_MAX_STRING_LEN + 1; private final ObjectMapper MAPPER = newJsonMapper(); From b898bda09ab131191a9c6507d09537862333e1ed Mon Sep 17 00:00:00 2001 From: joohyukkim Date: Sun, 14 May 2023 16:16:48 +0900 Subject: [PATCH 2/5] Make test excessive values dynamic --- .../databind/deser/dos/DeepJsonNodeDeser3397Test.java | 3 ++- .../databind/deser/dos/DeepNestingUntypedDeserTest.java | 5 +++-- .../databind/deser/dos/StreamReadStringConstraintsTest.java | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepJsonNodeDeser3397Test.java b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepJsonNodeDeser3397Test.java index f846453282..9281373f4a 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepJsonNodeDeser3397Test.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepJsonNodeDeser3397Test.java @@ -13,7 +13,8 @@ public class DeepJsonNodeDeser3397Test extends BaseMapTest // ... currently gets a bit slow at 1M but passes. // But test with 100k as practical limit, to guard against regression // private final static int TOO_DEEP_NESTING = 1_000_000; - private final static int TOO_DEEP_NESTING = 10_000; + private final static int TOO_DEEP_NESTING = StreamReadConstraints.DEFAULT_MAX_DEPTH * 10 < 0 + ? Integer.MAX_VALUE : StreamReadConstraints.DEFAULT_MAX_DEPTH * 10; private final JsonFactory jsonFactory = JsonFactory.builder() .streamReadConstraints(StreamReadConstraints.builder().maxNestingDepth(Integer.MAX_VALUE).build()) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java index 963040b9af..23630a26ba 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java @@ -1,5 +1,6 @@ package com.fasterxml.jackson.databind.deser.dos; +import static com.fasterxml.jackson.core.StreamReadConstraints.DEFAULT_MAX_DEPTH; import java.util.List; import java.util.Map; @@ -18,14 +19,14 @@ public class DeepNestingUntypedDeserTest extends BaseMapTest // 31-May-2022, tatu: But no more! Can handle much much larger // nesting levels, bounded by memory usage not stack. Tested with // 1 million (!) nesting levels, but to keep tests fast use 100k - private final static int TOO_DEEP_NESTING = 100_000; + private final static int TOO_DEEP_NESTING = StreamReadConstraints.DEFAULT_MAX_DEPTH * 100 < 0 + ? Integer.MAX_VALUE : StreamReadConstraints.DEFAULT_MAX_DEPTH * 100; private final JsonFactory jsonFactory = JsonFactory.builder() .streamReadConstraints(StreamReadConstraints.builder().maxNestingDepth(Integer.MAX_VALUE).build()) .build(); private final ObjectMapper MAPPER = JsonMapper.builder(jsonFactory).build(); - public void testFormerlyTooDeepUntypedWithArray() throws Exception { final String doc = _nestedDoc(TOO_DEEP_NESTING, "[ ", "] "); diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java index c13df305b0..5945914e6d 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java @@ -32,7 +32,8 @@ void setString(String string) { /********************************************************************** */ - private final static int TOO_LONG_STRING_VALUE = StreamReadConstraints.DEFAULT_MAX_STRING_LEN + 1; + private final static int TOO_LONG_STRING_VALUE = StreamReadConstraints.DEFAULT_MAX_STRING_LEN + 100 < 0 + ? Integer.MAX_VALUE : StreamReadConstraints.DEFAULT_MAX_STRING_LEN + 100; private final ObjectMapper MAPPER = newJsonMapper(); From 7fe9b91ddfb8661db737be5942394595e74fcd9c Mon Sep 17 00:00:00 2001 From: joohyukkim Date: Sun, 14 May 2023 16:23:06 +0900 Subject: [PATCH 3/5] Update DeepNestingUntypedDeserTest.java --- .../jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java index 23630a26ba..4cb9dbeef5 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java @@ -1,6 +1,5 @@ package com.fasterxml.jackson.databind.deser.dos; -import static com.fasterxml.jackson.core.StreamReadConstraints.DEFAULT_MAX_DEPTH; import java.util.List; import java.util.Map; From 25fb09ad7803da73abdb156425a8841f1222887c Mon Sep 17 00:00:00 2001 From: joohyukkim Date: Sun, 14 May 2023 16:32:19 +0900 Subject: [PATCH 4/5] Remove unnecessary changes. --- .../jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java index 4cb9dbeef5..6748397a20 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java @@ -26,6 +26,7 @@ public class DeepNestingUntypedDeserTest extends BaseMapTest .build(); private final ObjectMapper MAPPER = JsonMapper.builder(jsonFactory).build(); + public void testFormerlyTooDeepUntypedWithArray() throws Exception { final String doc = _nestedDoc(TOO_DEEP_NESTING, "[ ", "] "); From 2b2fa5aa21d1b3c637e87d25bf12c36ea8713e26 Mon Sep 17 00:00:00 2001 From: joohyukkim Date: Sun, 14 May 2023 17:58:50 +0900 Subject: [PATCH 5/5] simplify value. --- .../jackson/databind/deser/dos/DeepJsonNodeDeser3397Test.java | 3 +-- .../databind/deser/dos/DeepNestingUntypedDeserTest.java | 3 +-- .../databind/deser/dos/StreamReadStringConstraintsTest.java | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepJsonNodeDeser3397Test.java b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepJsonNodeDeser3397Test.java index 9281373f4a..adbf3e051d 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepJsonNodeDeser3397Test.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepJsonNodeDeser3397Test.java @@ -13,8 +13,7 @@ public class DeepJsonNodeDeser3397Test extends BaseMapTest // ... currently gets a bit slow at 1M but passes. // But test with 100k as practical limit, to guard against regression // private final static int TOO_DEEP_NESTING = 1_000_000; - private final static int TOO_DEEP_NESTING = StreamReadConstraints.DEFAULT_MAX_DEPTH * 10 < 0 - ? Integer.MAX_VALUE : StreamReadConstraints.DEFAULT_MAX_DEPTH * 10; + private final static int TOO_DEEP_NESTING = StreamReadConstraints.DEFAULT_MAX_DEPTH * 10; private final JsonFactory jsonFactory = JsonFactory.builder() .streamReadConstraints(StreamReadConstraints.builder().maxNestingDepth(Integer.MAX_VALUE).build()) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java index 6748397a20..6389da8841 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/dos/DeepNestingUntypedDeserTest.java @@ -18,8 +18,7 @@ public class DeepNestingUntypedDeserTest extends BaseMapTest // 31-May-2022, tatu: But no more! Can handle much much larger // nesting levels, bounded by memory usage not stack. Tested with // 1 million (!) nesting levels, but to keep tests fast use 100k - private final static int TOO_DEEP_NESTING = StreamReadConstraints.DEFAULT_MAX_DEPTH * 100 < 0 - ? Integer.MAX_VALUE : StreamReadConstraints.DEFAULT_MAX_DEPTH * 100; + private final static int TOO_DEEP_NESTING = StreamReadConstraints.DEFAULT_MAX_DEPTH * 100; private final JsonFactory jsonFactory = JsonFactory.builder() .streamReadConstraints(StreamReadConstraints.builder().maxNestingDepth(Integer.MAX_VALUE).build()) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java index 5945914e6d..5224c0b57d 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/dos/StreamReadStringConstraintsTest.java @@ -32,8 +32,7 @@ void setString(String string) { /********************************************************************** */ - private final static int TOO_LONG_STRING_VALUE = StreamReadConstraints.DEFAULT_MAX_STRING_LEN + 100 < 0 - ? Integer.MAX_VALUE : StreamReadConstraints.DEFAULT_MAX_STRING_LEN + 100; + private final static int TOO_LONG_STRING_VALUE = StreamReadConstraints.DEFAULT_MAX_STRING_LEN + 100; private final ObjectMapper MAPPER = newJsonMapper();