Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-155

Union Codec serialize throws Class cast when the union object is passed

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • None
    • None
    • Operating System: Mac OS
      Platform: PC

    • 973
    • Normal

    Description

      I have a union type in my yang schema

      leaf port-number {
      type union

      { type uint32; type string; }

      }

      through which it creates a PortNumber object.

      But the Union codec UnionCodecStringImpl.serialize accepts a String and not the union object PortNumber.

      The serialize() should be able to look for the types within the UnionTypeDefinition and return back the non-null value of the union.

      Following is the error i am getting:
      osgi> 2014-05-05 18:25:52.634 PDT [http-bio-8080-exec-8] ERROR o.o.y.y.d.i.c.xml.XmlDocumentUtils - Provided node value PortNumber [_string=LOCAL] did not have type type (urn:ietf:params:xml:ns:yang:1)union (types=[, uint32, string] required by mapping. Using stream instead.
      java.lang.ClassCastException: org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.CommonPort$PortNumber cannot be cast to java.lang.String
      at org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec$UnionCodecStringImpl.serialize(TypeDefinitionAwareCodec.java:548) ~[bundlefile:na]
      at org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils.writeValueByType(XmlDocumentUtils.java:257) [bundlefile:na]
      at org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils.writeValueByType(XmlDocumentUtils.java:218) [bundlefile:na]
      at org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils.createXmlRootElement(XmlDocumentUtils.java:168) [bundlefile:na]
      at org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils.createXmlRootElement(XmlDocumentUtils.java:189) [bundlefile:na]
      at org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils.createXmlRootElement(XmlDocumentUtils.java:189) [bundlefile:na]
      at org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils.toDocument(XmlDocumentUtils.java:112) [bundlefile:na]

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              kramesha@cisco.com Kamal Rameshan
              kramesha@cisco.com Kamal Rameshan
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: