[YANGTOOLS-742] Getter of BA object fails to construct class instance Created: 08/Feb/17 Updated: 10/Apr/22 Resolved: 15/Mar/17 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| 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 |
||
| Attachments: |
|
| External issue ID: | 7759 |
| Priority: | High |
| Description |
|
Deserialization fails with following exception: Caused by: java.lang.IllegalArgumentException: Failed to construct instance of class org.opendaylight.yang.gen.v1.urn.ieee.params.xml.ns.yang.dot1q.types.rev150626.dot1q.tag.or.any.Dot1qTag$VlanId for input 2420 when I do dot1qTag.getVlanId() here is yang model: after debugging, I found that EncapsulatedValueCodec.deserialize() fails because of java.lang.ClassCastException: Cannot cast java.lang.String to java.lang.Integer In case if I use analogous restconf request, DataObject is retrieved from cache The same request works if we downgrade odl dependencies to Beryllium-SR2. I noticed that in case of beryllium, the generated Dot1qTagVlanIdBuilder was invoked. |
| Comments |
| Comment by Marek Gradzki [ 08/Feb/17 ] |
|
Attachment netconf.txt has been added with description: netconf request |
| Comment by Marek Gradzki [ 08/Feb/17 ] |
|
Attachment restconf.txt has been added with description: restconf request |
| Comment by Marek Gradzki [ 08/Feb/17 ] |
|
Honeycomb log https://jira.fd.io/secure/attachment/11007/full_honeycomb.zip |
| Comment by Ivan Hrasko [ 20/Feb/17 ] |
|
Netconf request is working fine in stable/boron (except that you are missing <type> attribute in the rpc with id m-67). |
| Comment by Marek Gradzki [ 20/Feb/17 ] |
|
You are refering to SR2 or SR3 snapshot? |
| Comment by Ivan Hrasko [ 20/Feb/17 ] |
|
I added <type/> and result is: <rpc message-id="m-67" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> |
| Comment by Ivan Hrasko [ 20/Feb/17 ] |
|
Working rest request: PUT http://localhost:8181/restconf/config/ietf-interfaces:interfaces/interface/GigabitEthernet0%2F8%2F0 { } |
| Comment by Marek Gradzki [ 20/Feb/17 ] |
|
GigabitEthernet0/8/0 was defined in cfg before edit-cfg msg was received (perhaps this is why mandatory type attribute was not included in the series of messages). What we are more interesting in Have you checked boron SR2? |
| Comment by Ivan Hrasko [ 20/Feb/17 ] |
|
Yes I have checked release/boron-sr2 release and it worked fine. |
| Comment by Marek Gradzki [ 21/Feb/17 ] |
|
It is possible it works for honeycomb/vbd alone. But our setup is a bit different. ODL app (honeycomb/vbd) sends netconf requests to hc2vpp. Then hc2vpp fails to deserialize vlan-id union type. Please look at attached logs (DEBUG). Let me know if you need additional logs or increasing log level for some components to reproduce issue. Ultimate solution to reproduce bug is to install and run hc2vpp https://docs.fd.io/hc2vpp/1.17.01-SNAPSHOT/release-notes-aggregator/release_notes.html#_install_guide (will try to simplify the setup). |
| Comment by Ivan Hrasko [ 23/Feb/17 ] |
|
cherry picked https://git.opendaylight.org/gerrit/#/c/52203/ |
| Comment by Ivan Hrasko [ 27/Feb/17 ] |
|
Steps to reproduce: Add to software repositories: then install: sudo apt-get install vpp vpp-lib the start vpp: sudo service vpp start check: Download from honeycomb (if you want to change odl dependencies) and hc2vpp. Build hc2vpp and run it: Debugging port is 5005. You can connect to honeycomb: Send hello message and run rpcs from file local0.txt (this file uses interface local0) Check if interface local0 exists and/or create it with postman.collection.json. |
| Comment by Ivan Hrasko [ 27/Feb/17 ] |
|
Attachment local0.txt has been added with description: local0.txt file with requests to reproduce bug |
| Comment by Ivan Hrasko [ 27/Feb/17 ] |
|
Attachment postman.collection.json has been added with description: postman.collection.json file |
| Comment by Ivan Hrasko [ 27/Feb/17 ] |
|
In honeycomb project an hcv2vpp I used branch (stable/1701. honeycomb and hc2vpp sources can be downloaded from: |
| Comment by Ivan Hrasko [ 27/Feb/17 ] |
|
In honeycomb master they use workaround: |
| Comment by Marek Gradzki [ 08/Mar/17 ] |
|
I also noticed that union types handling in general fails in our scenario Perhaps some simple model with union type would speed up issue identification. We use BindingToNormalizedNodeCodec for BA<>BI translation: StreamWriterGenerator serializerGenerator = ... codec.fromNormalizedNode(id, data) BI data we deserialize is present in the full log If it is not enough to reproduce issue with non HC environment, |
| Comment by Ivan Hrasko [ 09/Mar/17 ] |
|
In Beryllium-2 it worked because there was always used string constructor to deserialize. Now there is type checking, so data must have correct type. Problem is probably somewhere outside mdsal. |
| Comment by Jakub Toth [ 09/Mar/17 ] |
|
Hi, I tried to write test for this (added you to review) - https://git.opendaylight.org/gerrit/#/c/53067/ - and it seems to be working for us (mdsal). Can you confirm this test? Thanks |
| Comment by Marek Gradzki [ 09/Mar/17 ] |
|
We use ModuleInfoBackedContext, except for that test looks good. Codec and schema service is shared among various ODL componets, Will try to simplify the setup needed to reproduce issue... |
| Comment by Marek Gradzki [ 10/Mar/17 ] |
|
Here is simplified version of our setup with instructions how to reproduce issue: https://gerrit.fd.io/r/#/c/5699/2 I checked also SR3 snapshots: https://gerrit.fd.io/r/#/c/5699/3 and the issue is also present |
| Comment by Jakub Toth [ 14/Mar/17 ] |
|
Codecs prepared in mdsal are used only in mdsal with specific input data. I added test to previous test[0] - negative test - where input data (NormalizedNode) contains other type of value like it is defined by yang and I got your case with IllegalArgumentException. This mean, that you have to have good type of value in input data according to type of value define by yang. This is why you can't deserialize input data with string if there has to be int. Our codecs are OK + generated code from yangs is OK. |
| Comment by Robert Varga [ 14/Mar/17 ] |
|
Looking at the log, I see the following: 2017-02-08 09:57:18.527 CET [netconf-netty-1] DEBUG o.o.y.b.d.c.i.UnionValueOptionContext - Codec org.opendaylight.yangtools.binding.data.codec.impl.EnumerationCodec@1b169815 failed to deserialize input 2420 Based on the example case you have provided, this makes sense, your JSON has quotes around the number, which means it is a String and treated as such, hence the integer-based union members are immediately skipped and it hits EnumerationCodec directly. At some point we will need to parse values more strictly in the JSON/XML world, but that is a change we cannot do this late in the release. |
| Comment by Robert Varga [ 14/Mar/17 ] |
|
Looking at the codec infrastructure, though, I am failing to see how that string could have passed through. Are you getting the same results via RESTCONF and NETCONF? |
| Comment by Robert Varga [ 14/Mar/17 ] |
|
Looking at the various classes, I am not sure which codec we are hitting and they do have slight variances: does the wrong thing by returning the original string representation and it seems to be hooked into NETCONF. https://github.com/opendaylight/yangtools/blob/master/yang/yang-data-util/src/main/java/org/opendaylight/yangtools/yang/data/util/AbstractStringUnionCodec.java seems to be doing the right thing (in most cases, I am not sure about edge cases) and is hooked into RESTCONF (for both XML and JSON). I am positive MD-SAL is off the hook and this needs to be fixed either in yangtools (by fixing the old codecs) or (better) netconf (by switching to yang-data-codec-xml). Can you guys confirm the following: 1) this issue occurs when the data is introduced via RESTCONF (if HC has such a thing) (both XML and JSON formats) After we have the results we can decide which strategy to take. |
| Comment by Robert Varga [ 14/Mar/17 ] |
|
I stand corrected, netconf is still using yang-data-impl XML codecs across the board. |
| Comment by Robert Varga [ 14/Mar/17 ] |
|
This needs to gate Boron-3, because it is a regression from a previous release. |
| Comment by Robert Varga [ 14/Mar/17 ] |
| Comment by Jakub Morvay [ 14/Mar/17 ] |
|
(In reply to Robert Varga from comment #25) Yeah, you are correct. Netconf and also Restconf is using data.impl.schema.transform parser/serializer infrastructure. |
| Comment by Robert Varga [ 14/Mar/17 ] |
| Comment by Jan Srnicek [ 15/Mar/17 ] |
|
Verified with test patch https://gerrit.fd.io/r/#/c/5699/, no issue present |
| Comment by Jan Srnicek [ 15/Mar/17 ] |
|
(In reply to Jan Srnicek from comment #30) |