[MDSAL-214] Instance identifier can't be used in union Created: 22/Dec/16  Updated: 09/Mar/18  Resolved: 12/Jan/17

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

Type: Bug
Reporter: Richard Kosegi Assignee: Vratko Polak
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 7425

 Description   

Following YANG is not compilable by yangtools:

module demo {
namespace "urn:opendaylight:demo";
prefix "demo";
revision "2016-12-22";

typedef some-type {
type union

{ type instance-identifier; type string; }

}
}

Yangtools generated source code requires union members to have method "String getValue()", which is not case of built-in type InstanceIdentifier.
This results in compilation error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project test-model: Compilation failure
[ERROR] demo/target/generated-sources/mdsal-binding/org/opendaylight/yang/gen/v1/urn/opendaylight/demo/rev161222/SomeType.java:[63,45] cannot find symbol
[ERROR] symbol: method getValue()
[ERROR] location: variable _instanceIdentifier of type org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?>

This is generated code (SomeType.java):

60 public char[] getValue() {
61 if (_value == null) {
62 if (_instanceIdentifier != null)

{ 63 _value = _instanceIdentifier.getValue().toString().toCharArray(); 64 }

else
65 if (_string != null)

{ 66 _value = _string.toCharArray(); 67 }

68 }
69 return _value == null ? null : _value.clone();
70 }



 Comments   
Comment by Peter Kajsa [ 22/Dec/16 ]

It is a binding generator issue, hence moved to md-sal.

Comment by Vratko Polak [ 04/Jan/17 ]

I lack the skill to make a proper unit test, and I am not sure the following is allowed from architecture point of view, but anyway:

A failing change showing this Bug is real: https://git.opendaylight.org/gerrit/50017
A simple workaround: https://git.opendaylight.org/gerrit/#/c/50019/
Analogous change chowing the workaround works: https://git.opendaylight.org/gerrit/#/c/50020/

(Verify jobs are still in queue. I hope I did not make any mistake when building locally.)

Comment by Vratko Polak [ 04/Jan/17 ]

> I hope I did not make any mistake

Looks like no mistake, verification results are as expected.

Comment by Vratko Polak [ 05/Jan/17 ]

> A simple workaround

... got -1.

Better fix: https://git.opendaylight.org/gerrit/50070
Verification: https://git.opendaylight.org/gerrit/#/c/50020/2

Comment by Robert Varga [ 06/Jan/17 ]

boron: https://git.opendaylight.org/gerrit/50088

Comment by Martin Ciglan [ 12/Jan/17 ]

fix for binding spec v2, carbon:

https://git.opendaylight.org/gerrit/#/c/50283/

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