-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Handle circular references in Java beans #645
Conversation
new JSONObject(ObjA); | ||
} | ||
@Test(expected=JSONException.class) | ||
public void testRepeatObjectRecursive() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test should not throw an exception. There is no recursion here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your reply @johnjaylward ! Could you please explain a little more about why this test case is not recursive? I assumed this test case was recursive because it starts with C and ends with C in both children branches, creating loops of C-B-A-D-C... I also ran the test and it seems there would be an Exception thrown. Thanks for your patience!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you are correct! My eyes glazed over the first C for some reason.
As additional tests, can you make these:
Self recursion, should throw exception:
A -> A
B -> A -> A
Complex graph, duplicate object(s), but no recursion (no exception thrown):
E -> B -> A -> D -> C
-> D -> C
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional test cases added
This looks like a much better approach for implementation than the first go-around. Just needs a a few corrections to make that one test not throw an exception. |
@stleary can you approve the workflow? |
What problem does this code solve? Risks Changes to the API? Will this require a new release? Should the documentation be updated? Does it break the unit tests? Was any code refactored in this commit? Review status |
Starting 3 day comment window |
Try to achieve the recursive check within one pass
Added some related test cases