fix(java): reproduce silent Set child-loss for package-private nodes - #3902
fix(java): reproduce silent Set child-loss for package-private nodes#3902PiotrDuz wants to merge 2 commits into
Conversation
…in cyclic graphs Wide fan-out (one parent, many children) cyclic graph of package-private nodes loses entries from a Set<PackagePrivateType> field on deserialize - no exception, unlike the codegen CompileException PackagePrivateMapKeyTest guards against. Reproduced from a production graph with 100+ children under one node; the child->parent back-reference (EnumMap-keyed) survives the round trip, the parent->child Set does not.
wenshao
left a comment
There was a problem hiding this comment.
[Critical] PR adds a test that reproduces an active bug (issue #3903) but contains no production code fix. CI confirms all Java jobs fail (Java CI 8/11/17/21/25/26, Openj9, Windows, Code Style Check). Merging would break main with a permanently failing test. The fix(java): commit type signals a bug fix but delivers only a regression test. Either include the production fix, mark the test @ignore with a link to #3903, or change the commit type to test.
— qwen3.8-max-preview via Qwen Code /review
|
After reviewing this issue, cyclic references should not be used as This happened to work previously because the relevant The recommended workaround is to serialize the cyclic references as a private List<Node> parentList = new ArrayList<>();
private transient Set<Node> parents;
public Set<Node> getParents() {
if (parents == null) {
parents = new LinkedHashSet<>(parentList);
}
return parents;
}The same approach can be used for maps by serializing an ordered list of key-value entries and constructing the map after the object graph has been fully deserialized. Lists, arrays, object fields, and map values may still contain cyclic references; the limitation applies specifically to cyclic objects used as set elements or map keys. |
## Why? ## What does this PR do? ## Related issues Closes #3903 #3902 ## AI Contribution Checklist - [ ] Substantial AI assistance was used in this PR: `yes` / `no` - [ ] If `yes`, I included a completed [AI Contribution Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs) in this PR description and the required `AI Usage Disclosure`. - [ ] If `yes`, my PR description includes the required `ai_review` summary and screenshot evidence or equivalent persisted links of the final clean AI review results from both fresh reviewers described in `AI_POLICY.md`, the Fory-guided reviewer and the independent general reviewer, on the current PR diff or current HEAD after the latest code changes. ## Does this PR introduce any user-facing change? - [ ] Does this PR introduce any public API change? - [ ] Does this PR introduce any binary protocol compatibility change? ## Benchmark
cyclic graphs
Wide fan-out (one parent, many children) cyclic graph of package-private nodes loses entries from a Set field on deserialize - no exception.
Why?
fory had a regression bug of cyclic graph losing edges. Want to pin it so no further regressions are possible.
What does this PR do?
This PR adds a test case that reproduces the regression
Related issues
#3903
AI Contribution Checklist
The test has been generated by AI, but the idea and guidance is human - the problem and its reporduction in version 1.1.0 is tested by hand.