[MDSAL-253] BindingToNormalizedNodeCodec fails to deserialize union of leafrefs Created: 15/May/17  Updated: 01/Mar/18  Resolved: 01/Mar/18

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

Type: Bug
Reporter: Marek Gradzki 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
Platform: All


Attachments: Text File honeycomb.log.txt    
Issue Links:
Blocks
blocks MDSAL-304 Binding V2 maps identities to java.la... Resolved
Relates
relates to MDSAL-269 Error occurs when mdsal binding v1 co... Resolved
External issue ID: 8449
Priority: Normal

 Description   

Here is model example:

typedef name1-ref {
type leafref

{ path "/tst:top/tst:name1"; }

}

typedef name2-ref {
type leafref

{ path "/tst:top/tst:name2"; }

}

container top {
leaf name1

{ type string; }
leaf name2 { type string; }

}

container cont {
leaf ref {
type union

{ type name1-ref; type name2-ref; }

mandatory true;
}
}

Deserializing:

"cont":

{ "ref": "some-name" }

Gives following exception:
2017-05-15 13:45:14.761 CEST [qtp114012533-50] WARN o.e.jetty.servlet.ServletHandler - /restconf/config/test:cont/
java.lang.IllegalStateException: Unable to load codec for class org.opendaylight.yang.gen.v1.urn.test.rev170101.Cont$Ref
at org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext.getCodecForBindingClass(BindingCodecContext.java:306) ~[mdsal-binding-dom-codec-0.9.3-Boron-SR3.jar:na]

[...]

Caused by: java.lang.NoSuchMethodException: org.opendaylight.yang.gen.v1.urn.test.rev170101.Cont$Ref.getName1Ref()
at java.lang.Class.getMethod(Class.java:1786) ~[na:1.8.0_45-internal]
at org.opendaylight.yangtools.binding.data.codec.impl.UnionTypeCodec.lambda$loader$0(UnionTypeCodec.java:33) ~[mdsal-binding-dom-codec-0.9.3-Boron-SR3.jar:na]
at org.opendaylight.yangtools.binding.data.codec.impl.UnionTypeCodec$$Lambda$106/1574798546.call(Unknown Source) ~[na:na]
at org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext.getCodecForBindingClass(BindingCodecContext.java:304) ~[mdsal-binding-dom-codec-0.9.3-Boron-SR3.jar:na]

Full trace included.



 Comments   
Comment by Marek Gradzki [ 15/May/17 ]

Attachment honeycomb.log.txt has been added with description: honeycomb log

Comment by Jakub Toth [ 22/May/17 ]

Hi,

can you try this patch, please ?

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

Let me know about results, please.

Thanks

Comment by Marek Gradzki [ 23/May/17 ]

It works for the example I attached. But the underlying issue we had was with following model:

https://gerrit.fd.io/r/#/c/6658/2/v3po/api/src/main/yang/unnumbered-interfaces.yang@26

And this is still failing, but with different exception:
java.lang.IllegalStateException: Unable to load codec for class org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unnumbered.interfaces.rev170510.unnumbered.config.attributes.Unnumbered$Use
at org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext.getCodecForBindingClass(BindingCodecContext.java:306) ~[mdsal-binding-dom-codec-0.9.4-SNAPSHOT.jar:na]

[...]

Caused by: java.lang.NoSuchMethodException: org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unnumbered.interfaces.rev170510.unnumbered.config.attributes.Unnumbered$Use.getUint32UseValue()
at java.lang.Class.getMethod(Class.java:1786) ~[na:1.8.0_45-internal]
at org.opendaylight.yangtools.binding.data.codec.impl.UnionTypeCodec.lambda$loader$1(UnionTypeCodec.java:57) ~[mdsal-binding-dom-codec-0.9.4-SNAPSHOT.jar:na]
at org.opendaylight.yangtools.binding.data.codec.impl.UnionTypeCodec$$Lambda$144/1975802955.call(Unknown Source) ~[na:na]
at org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext.getCodecForBindingClass(BindingCodecContext.java:304) ~[mdsal-binding-dom-codec-0.9.4-SNAPSHOT.jar:na]
... 75 common frames omitted

Comment by Jakub Toth [ 23/May/17 ]

(In reply to Marek Gradzki from comment #3)
> It works for the example I attached. But the underlying issue we had was
> with following model:
>
> https://gerrit.fd.io/r/#/c/6658/2/v3po/api/src/main/yang/unnumbered-
> interfaces.yang@26
>
> And this is still failing, but with different exception:
> java.lang.IllegalStateException: Unable to load codec for class
> org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unnumbered.
> interfaces.rev170510.unnumbered.config.attributes.Unnumbered$Use
> at
> org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext.
> getCodecForBindingClass(BindingCodecContext.java:306)
> ~[mdsal-binding-dom-codec-0.9.4-SNAPSHOT.jar:na]
>
> [...]
>
> Caused by: java.lang.NoSuchMethodException:
> org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unnumbered.
> interfaces.rev170510.unnumbered.config.attributes.Unnumbered$Use.
> getUint32UseValue()
> at java.lang.Class.getMethod(Class.java:1786) ~[na:1.8.0_45-internal]
> at
> org.opendaylight.yangtools.binding.data.codec.impl.UnionTypeCodec.
> lambda$loader$1(UnionTypeCodec.java:57)
> ~[mdsal-binding-dom-codec-0.9.4-SNAPSHOT.jar:na]
> at
> org.opendaylight.yangtools.binding.data.codec.impl.
> UnionTypeCodec$$Lambda$144/1975802955.call(Unknown Source) ~[na:na]
> at
> org.opendaylight.yangtools.binding.data.codec.impl.BindingCodecContext.
> getCodecForBindingClass(BindingCodecContext.java:304)
> ~[mdsal-binding-dom-codec-0.9.4-SNAPSHOT.jar:na]
> ... 75 common frames omitted

OK, fixed. I missed to do conversion of YANG type to Java type.

Comment by Marek Gradzki [ 23/May/17 ]

Thanks. Retested and it works now.

Comment by Martin Ciglan [ 12/Jun/17 ]

at some point, this needs cherry-pick to Carbon for binding spec v1. Back to CONFIRMED

Comment by Jakub Toth [ 21/Jul/17 ]

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

Comment by Jakub Toth [ 24/Jul/17 ]

+ master: https://git.opendaylight.org/gerrit/#/c/60698/

Comment by Robert Varga [ 30/Jan/18 ]

Binding V2 is not fixed, the patch needs to be ported.

Comment by Jie Han [ 07/Feb/18 ]

Binding v2: https://git.opendaylight.org/gerrit/67990

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