Repository navigation
feat(java): add cycle detection and depth limit to JSON serializer - #383
Open
buongarzoni wants to merge 1 commit into
Open
buongarzoni wants to merge 1 commit into
buongarzoni wants to merge 1 commit into
Conversation
AI Agent Review LGTM (openai, openai-astra)LGTM. No blocking findings were found. LGTM. No defects confirmed on the changed lines. I did not run the tests; everything below comes from reading the code in the checkout. What I verified
Notes outside the changed lines (not findings)
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the change
JsonSerializerImplhad no depth limit and no cycle detection. User data that contains itself (e.g.map.put("self", map)) caused aStackOverflowErroron the caller's thread, and very deeply nested data produced huge payloads.Changes
"<circular reference>". The same value reached twice without a cycle is still serialized both times.maxDepth(default 100) are written as"<max depth exceeded>". Neither case throws.JsonSerializerImpl(boolean prettyPrint, int maxDepth)sets the limit; use it withConfigBuilder.jsonSerializer(...).Tests
Added tests for cycles through maps, collections, arrays and
JsonSerializable, a shared value that isn't a cycle, a custommaxDepth, 100,000 levels of nesting (previously a stack overflow), and rejecting amaxDepthbelow 1.Type of change
Related issues
Checklists
Development
Code review