[YANGTOOLS-1538] Do not use Optional in yang-data-tree-ri operations Created: 04/Sep/23 Updated: 20/Oct/23 Resolved: 20/Oct/23 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | data-impl |
| Affects Version/s: | None |
| Fix Version/s: | 12.0.0, 11.0.4 |
| Type: | Improvement | Priority: | Medium |
| Reporter: | Robert Varga | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | pt | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
We are using Optional<? extends TreeNode> as baseline metadata against we validate the tree – throughout ModificationApplyOperation – both as an argument and as a return value. While the return value might be appropriate, the use as arguments is not (as we are not religious about them as some others. This also leads us to store Optionals as fields, which leaks them to the heap, which means we have some amount of overhead unless the JVM can prove an InMemoryModification does not leak to heap. That always happens by the very design. Convert use of Optional<? extends TreeNode> to @Nullable TreeNode and explicitly annotate pre-existing uses of plain TreeNode references as @NonNull. |