[MDSAL-2] Naming conflict appears when key of list is constructed from leaf with name key Created: 20/Nov/13 Updated: 04/Jun/18 Resolved: 04/Jun/18 |
|
| Status: | Resolved |
| Project: | mdsal |
| Component/s: | Binding codegen |
| Affects Version/s: | None |
| Fix Version/s: | Fluorine |
| Type: | Improvement | ||
| Reporter: | Martin Vitez | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: All |
||
| Issue Links: |
|
||||||||||||||||||||||||
| Description |
|
With following statement in yang model: list property { } exception is thrown: java.lang.ClassCastException: org.opendaylight.yangtools.binding.generator.util.Types$ConcreteTypeImpl cannot be cast to org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject This is caused because of 2 methods with same name (getKey) are generated, first for list statement to get key, second as a getter for leaf node. |
| Comments |
| Comment by Tony Tkacik [ 27/Feb/14 ] |
|
Solution is to rename getter getKey(), which was added by BindingGenerator This is API breakage, so it needs to be part of binding specification v2. |
| Comment by Jozef Gloncak [ 03/Mar/14 ] |
|
Working on it |
| Comment by Jozef Gloncak [ 03/Mar/14 ] |
|
status changed |
| Comment by Jozef Gloncak [ 04/Mar/14 ] |
|
According to RFC 6020 name of concrete container, leaf, leaf-list, list, Before this commit there was generated for key of a list getter method As was specified in bugzilla - interface (from YANG list) and implementing Name conflict for methods 'key()', 'keySet()', 'keyGet()' is solved Currently all yangtools projects were succesfuly built with this change. The commit is in draft state |
| Comment by Jozef Gloncak [ 05/Mar/14 ] |
|
test if methods 'get()', 'keyGet()', 'keySet()' are in builder, interface and interface implementation was added |
| Comment by Jozef Gloncak [ 30/Apr/14 ] |
|
The change was rebased on 30APR2014 |
| Comment by Sven Wisotzky [ 31/Oct/16 ] |
|
There are much more flavors of this error: In general I would agree, that renaming the method "getKey()" to something else like "whatKey()" would fix that issue. I am only concerned about the ongoing discussion, that getKey() might still be available for compatibility with existing "yang binding v1" integration projects - and it gets only removed in cases where naming conflicts occur. If going down that path, implementation should be smart enough, to not only check for leaves called "key" but other types like container or list as well. I am surprised that this is categorized as with importance "lowest" and "enhancement". The thing is basically, that this break with existing vendor YANG models - as key is very likely used as YANG variable name around protocol authentication and privacy (for example BGP keychains, IPsec, ...). In my eyes this is not just a corner case - it is a bug with major severity, beside we come to such conclusion that ODL should not be flexible enough to compile any valid/existing YANG model in the market. |
| Comment by Jakub Toth [ 24/Mar/17 ] |
| Comment by Robert Varga [ 23/Apr/18 ] |
|
Fluorine Binding V1 is cleared for this API breakage. Builders will use 'withKey()' instead of 'setKey()'. This also affects augmentations, where we need to just solve 'getAugmentation()', renaming it to 'augmentation()'. |