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
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7823d3a
locate the pace for cyclic check
b5bcb68
added set check logic
4565bdd
data class for recursive test
1ffcf39
successful test
638273a
long circle test
fb96e87
add test case and modified old ones
fca7e17
Added test cases for self recursion and complex but no recursion
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.json.junit.data; | ||
|
||
/** | ||
* test class for verifying if recursively defined bean can be correctly identified | ||
* @author Zetmas | ||
* | ||
*/ | ||
public class RecursiveBean { | ||
private String name; | ||
private Object reference; | ||
private Object reference2; | ||
public String getName() { return name; } | ||
public Object getRef() {return reference;} | ||
public Object getRef2() {return reference2;} | ||
public void setRef(Object refObj) {reference = refObj;} | ||
public void setRef2(Object refObj) {reference2 = refObj;} | ||
|
||
public RecursiveBean(String name) { | ||
this.name = name; | ||
reference = null; | ||
reference2 = null; | ||
} | ||
} |
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.
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:
Complex graph, duplicate object(s), but no recursion (no exception thrown):
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