[MDSAL-384] YANG Data Object List Getters should return Immutable Lists (in Binding v2, only) Created: 09/Nov/18  Updated: 09/Nov/18  Resolved: 09/Nov/18

Status: Resolved
Project: mdsal
Component/s: Binding V2 codegen
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Medium
Reporter: Michael Vorburger Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Unless I'm totally mistaken, the current (v1) binding generated YANG Data Object classes have List getters which return mutable collections. This inconsistent with the fact that Data Objects are otherwise immutable. We should make any collections returned by such getters immutable.

I believe I raised this 2 years ago on https://lists.opendaylight.org/pipermail/yangtools-dev/2016-July/001508.html & Co. including https://wiki.opendaylight.org/view/YANG_Tools:Design:Binding_Specification_v2_Analysis#Other_ideas_for_improving_the_v2_Binding_Spec but I cannot find an issue for this, so here it is.

This is obviously a breaking change, so impossible for Binding v1, but something for Binding v2.

The new non-null getters introduced in MDSAL-18 could then also return immutable empty lists, if null



 Comments   
Comment by Robert Varga [ 09/Nov/18 ]

The cost of sealing collections is quite huge, this simply does not pay off.

Generated at Wed Feb 07 20:09:40 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.