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.
This test should not throw an exception. There is no recursion here.
There was a problem hiding this comment.
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.
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.
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