Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hard-coded StreamReadConstraints test variables to isolate change in jackson-core itself #3930

Merged
merged 5 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are not going to make StreamReadConstraints.DEFAULT_MAX_DEPTH <=0 - this complicated statement is unnecessary - use TOO_DEEP_NESTING = StreamReadConstraints.DEFAULT_MAX_DEPTH * 10 - this goes for all the MAX values

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍🏻 thank you for the review. I also think it could simpler.

? Integer.MAX_VALUE : StreamReadConstraints.DEFAULT_MAX_DEPTH * 10;

private final JsonFactory jsonFactory = JsonFactory.builder()
.streamReadConstraints(StreamReadConstraints.builder().maxNestingDepth(Integer.MAX_VALUE).build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ 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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ 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 + 100 < 0
? Integer.MAX_VALUE : StreamReadConstraints.DEFAULT_MAX_STRING_LEN + 100;

private final ObjectMapper MAPPER = newJsonMapper();

Expand Down