[YANGTOOLS-408] Cast exception when serializing L3Address from groupbasedpolicy policy.yang Created: 07/Feb/15 Updated: 10/Apr/22 Resolved: 02/Mar/15 |
|
| Status: | Resolved |
| Project: | yangtools |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Thomas Bachman | Assignee: | Martin Ciglan |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Operating System: Mac OS |
||
| External issue ID: | 2689 |
| Priority: | Normal |
| Description |
|
We get the following stack trace: 2015-02-06 15:20:10,954 | INFO | DOM-OPER-DCL-1 | SwitchManager | 178 - org.opendaylight.groupbasedpolicy - 0.2.0.SNAPSHOT | New switch Uri [_value=openflow:2] connected This happens when we try to update an Endpoint we've read back from the data store with an augmentation, using the builder: EndpointBuilder epBuilder = new EndpointBuilder(ep); ... (update EP with augmentation) The exception happens when we put this into the write transaction (i.e. before submit): tx.put(LogicalDatastoreType.OPERATIONAL, iidEp, epBuilder.build()); We noticed that the Endpoint that we read from the data store (i.e. to do the update) has an empty augmentation in the L3Address: Endpoint{getCondition=[], getEndpointGroup=Uuid [_value=1eaf9a67-a171-42a8-9282-71cf702f61dd], getL2Context=Uuid [_value=7b796915-adf4-4356-b5ca-de005ac410c1], getL3Address=[L3Address{getIpAddress=IpAddress [_ipv4Address=Ipv4Address [_value=10.0.35.2], _value=[1, 0, ., 0, ., 3, 5, ., 2]], getL3Context=Uuid [_value=cbe0cc07-b8ff-451d-8171-9eef002a8e80], augmentations={}}], getMacAddress=MacAddress [_value=00:00:00:00:35:02], getPortName=Name [_value=vethl26839], getTenant=Uuid [_value=f5c7d344-d1c7-4208-8531-2c2693657e12], getTimestamp=1423266774630, augmentations={interface org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.ofoverlay.rev140528.OfOverlayContext=OfOverlayContext{}}} Here is the definition of the L3Address in the yang model: list l3-address { description "All the layer 3 addresses associated with this endpoint"; key "l3-context ip-address"; uses l3-key; }where: grouping l3-key { leaf ip-address { type inet:ip-address; mandatory true; description "The actual IP address for the endpoint"; }} (fwiw, the l3-context-id is just a UUID) The resulting interface for the corresponding Java class (L3Address) has this: public interface L3Address extends ChildOf<EndpointFields>, Augmentable<org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address>, L3Key, Identifiable<L3AddressKey> { ... }We are able to work around this for now by manually (re-)constructing the L3Address: List<L3Address> l3Addresses= new ArrayList<>(); However, it doesn't seem like we should have to do this. |
| Comments |
| Comment by Martin Ciglan [ 12/Feb/15 ] |
|
I wasn't able to get the error you have described. Could you please provide me more information about the part EndpointBuilder epBuilder = new EndpointBuilder(ep); ... (update EP with augmentation) especially augmentation please. Also, how is it connected to doing copy of l3address list in last part of your description. If you can attach source code, it will be great. Thanks. |
| Comment by Thomas Bachman [ 12/Feb/15 ] |
|
Here is the (merged) gerrit that added the code that triggered this: Line 360 is where the builder is created. The Endpoint used to initialize the builder comes from line 334. When we looked at the contents of this Endpoint using the Eclipse debugger, we noticed the empty augmentation (as shown in the description here). Lines 365 - 371 of this gerrit were added to re-initialize the L3Address in order to avoid this exception. |
| Comment by Martin Ciglan [ 12/Feb/15 ] |
|
Hi Thomas Thanks for additional information, I re-constructed Endpoint ep value based on your information. This is the state of ep, epBuilder and augmentation, getting it in similar way as you did with Eclipse debugger. I haven't got actual values for nodeId.getId() and nodeConnectorId.getId(), so I just used test values. epBuilder.getAugmentation().toString(): ep.toString(): epBuilder.build().toString(): Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.85 sec - in org.opendaylight.controller.md.sal.binding.impl.test.Bug2689GBPCastException Results : Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 |
| Comment by Thomas Bachman [ 12/Feb/15 ] |
|
I'm not sure if this makes a difference, but the Endpoint state we saw used augmentations={} (note the plural form, and curly brackets instead of non-curly brackets). The state you showed below has just augmentation=[]. |
| Comment by Martin Ciglan [ 13/Feb/15 ] |
|
Hi Thomas Issue replicated, debug in progress... java.lang.ClassCastException: Cannot cast org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.L3ContextId to org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress |
| Comment by Martin Ciglan [ 20/Feb/15 ] |
|
fix pushed: |
| Comment by Martin Ciglan [ 26/Feb/15 ] |
|
patch pushed: |