[MDSAL-552] Binding/DOM codec fails when leafref points to an enumeration Created: 06/May/20  Updated: 10/Jun/20  Resolved: 10/Jun/20

Status: Resolved
Project: mdsal
Component/s: Binding codegen
Affects Version/s: None
Fix Version/s: 4.0.15, 6.0.2, 5.0.12

Type: Bug Priority: Medium
Reporter: Peter Valka Assignee: Peter Valka
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File bug552.yang.txt    
Issue Links:
Relates
relates to YANGTOOLS-1110 Issue a warning when an identityref i... Resolved

 Description   

Enum values with names using underscores are encoded without underscores. This issue has been reproduced using such enum in Notification or Rpc through leaf-ref. Issue appears when Gson codec tries to writeValue. Refer to example yang model in attachment.



 Comments   
Comment by Robert Varga [ 07/May/20 ]

As noted in the code review, the test case seems to be showing the effect of a previous bug. Please update the test case to correctly show the bug.

Comment by Robert Varga [ 10/Jun/20 ]

After adjusting the test case, it is obvious the fault lies with mdsal-binding-dom-codec, which fails to perform proper encoding in both directions, as it is using no-op codec.

Comment by Robert Varga [ 10/Jun/20 ]

The test model also demonstrates that there is something wrong with base codegen, as the  target type is 'java.lang.Enum' whereas it should be OutputA. That may actually be the root cause for this behavior.

Comment by Robert Varga [ 10/Jun/20 ]

So the codec problem actually stems from the codegen problem – since the getter method has the wrong return type, we are ending up not looking up the proper codec and defaulting to no-op.

Comment by Robert Varga [ 10/Jun/20 ]

We seem to be using a different codepath (or ordering?), as a plain container with the same type of leaf works correctly, whereas RPC input ends up going to BaseYangTypes.javaTypeForYangType(), which is returning the java.lang.Enum we end up using.

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