<!-- 
RSS generated by JIRA (8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d) at Wed Feb 07 20:52:26 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>OpenDaylight JIRA</title>
    <link>https://jira.opendaylight.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.20.10</version>
        <build-number>820010</build-number>
        <build-date>22-06-2022</build-date>
    </build-info>


<item>
            <title>[YANGTOOLS-160] String needs to be changed to Object (or Enum) in the method TypeDefinitionAwareCodec$EnumCodecStringImpl.serialize</title>
                <link>https://jira.opendaylight.org/browse/YANGTOOLS-160</link>
                <project id="10188" key="YANGTOOLS">yangtools</project>
                    <description>&lt;p&gt;While following the md-sal tutorial on ping: &lt;a href=&quot;https://wiki.opendaylight.org/view/Ping&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://wiki.opendaylight.org/view/Ping&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I see the exception below when exercising the RPC rest call as shown:&lt;/p&gt;

&lt;p&gt;  &lt;a href=&quot;http://localhost:8080/restconf/operations/ping:send-echo&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://localhost:8080/restconf/operations/ping:send-echo&lt;/a&gt;&lt;br/&gt;
  With the following headers:&lt;br/&gt;
  Content-Type: application/yang.operation+json&lt;br/&gt;
  Cache-Control: no-cache&lt;br/&gt;
  and the data set to raw Json encoded data (for POSTMAN at least) &lt;br/&gt;
  { &quot;input&quot; : &lt;/p&gt;
{ &quot;destination&quot; : &quot;127.0.0.1&quot; }
&lt;p&gt; }&lt;/p&gt;


&lt;p&gt;&amp;#8212;&lt;/p&gt;

&lt;p&gt;From: Tom Pantelis &amp;lt;tompantelis@gmail.com&amp;gt;&lt;br/&gt;
Subject: Re: 2014-05-10 16:21:48.964 EDT &lt;span class=&quot;error&quot;&gt;&amp;#91;http-bio-8080-exec-7&amp;#93;&lt;/span&gt; ERROR o.o.c.sal.restconf.impl.RestCodec - ClassCastException was thrown when codec is invoked with parameter Unreachable java.lang.ClassCastException: org.opendaylight.yang.gen.v1.urn.opendaylight.ping.rev130911.SendEchoOutput$EchoResult cannot be cast to java.lang.String&lt;br/&gt;
Date: May 12, 2014 at 11:06:04 AM EDT&lt;br/&gt;
To: Flavio Fernandes &amp;lt;ffernand@redhat.com&amp;gt;&lt;/p&gt;

&lt;p&gt;That code is in the yangtools project - check the contributor list. I would say create a bug in the yangtools project to get the ball rolling. &lt;/p&gt;

&lt;p&gt;I definitely think String needs to be changed to Object (or Enum) in the method and generic type signatures similar to what was done in &lt;a href=&quot;https://jira.opendaylight.org/browse/YANGTOOLS-129&quot; title=&quot;TypeDefinitionAwareCodec fails on type empty&quot; class=&quot;issue-link&quot; data-issue-key=&quot;YANGTOOLS-129&quot;&gt;&lt;del&gt;YANGTOOLS-129&lt;/del&gt;&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;On Mon, May 12, 2014 at 9:21 AM, Flavio Fernandes &amp;lt;ffernand@redhat.com&amp;gt; wrote:&lt;/p&gt;

&lt;p&gt;Thanks, Tom. Yeah, I agree 100%. I played with TypeDefinitionAwareCodec.java as much as I could to make it work, but my Java skills are just&lt;br/&gt;
not there yet.&lt;/p&gt;

&lt;p&gt;Do you know who would be the most familiar with that code? I&#8217;m trying to reach Tony T. but no answer yet.&lt;/p&gt;

&lt;p&gt;Maybe he is busy at the OpenStack Summit.&lt;/p&gt;

&lt;p&gt;Chhers,&lt;/p&gt;

&lt;p&gt;&#8212; flavio&lt;/p&gt;


&lt;p&gt;On May 11, 2014, at 12:56 PM, Tom Pantelis &amp;lt;tompantelis@gmail.com&amp;gt; wrote:&lt;/p&gt;

&lt;p&gt;Flavio,&lt;/p&gt;

&lt;p&gt;I&apos;m not familiar with this code but it looks like the ex occurs  when invoking the EnumCodecStringImp.serialize method because the JVM can&apos;t cast the input parameter of type  EchoResult enum instance to a String.  It seems to me that EnumCodecStringImp.serialize should take an Object param - all it does anyway is return toString() on the param.&lt;/p&gt;

&lt;p&gt;Tom&lt;/p&gt;


&lt;p&gt;On Sat, May 10, 2014 at 6:17 PM, Flavio Fernandes &amp;lt;ffernand@redhat.com&amp;gt; wrote:&lt;br/&gt;
Hi Tom,&lt;/p&gt;

&lt;p&gt;While doing the MD-SAL tutorial on ping ( &lt;a href=&quot;https://wiki.opendaylight.org/view/Ping&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://wiki.opendaylight.org/view/Ping&lt;/a&gt; ), I hit an exception that looks like this:&lt;/p&gt;

&lt;p&gt;...&lt;br/&gt;
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) &lt;span class=&quot;error&quot;&gt;&amp;#91;na:1.7.0_51&amp;#93;&lt;/span&gt;&lt;br/&gt;
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) &lt;span class=&quot;error&quot;&gt;&amp;#91;na:1.7.0_51&amp;#93;&lt;/span&gt;&lt;br/&gt;
	at java.lang.Thread.run(Thread.java:744) &lt;span class=&quot;error&quot;&gt;&amp;#91;na:1.7.0_51&amp;#93;&lt;/span&gt;&lt;br/&gt;
2014-05-10 16:21:48.964 EDT &lt;span class=&quot;error&quot;&gt;&amp;#91;http-bio-8080-exec-7&amp;#93;&lt;/span&gt; ERROR o.o.c.sal.restconf.impl.RestCodec - ClassCastException was thrown when codec is invoked with parameter Unreachable&lt;br/&gt;
java.lang.ClassCastException: org.opendaylight.yang.gen.v1.urn.opendaylight.ping.rev130911.SendEchoOutput$EchoResult cannot be cast to java.lang.String&lt;br/&gt;
	at org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec$EnumCodecStringImpl.serialize(TypeDefinitionAwareCodec.java:512) ~&lt;span class=&quot;error&quot;&gt;&amp;#91;bundlefile:na&amp;#93;&lt;/span&gt;&lt;br/&gt;
	at org.opendaylight.controller.sal.restconf.impl.RestCodec$ObjectCodec.serialize(RestCodec.java:141) ~&lt;span class=&quot;error&quot;&gt;&amp;#91;bundlefile:na&amp;#93;&lt;/span&gt;&lt;br/&gt;
	at org.opendaylight.controller.sal.rest.impl.JsonMapper.writeValueOfNodeByType(JsonMapper.java:240) &lt;span class=&quot;error&quot;&gt;&amp;#91;bundlefile:na&amp;#93;&lt;/span&gt;&lt;br/&gt;
	at org.opendaylight.controller.sal.rest.impl.JsonMapper.writeLeaf(JsonMapper.java:193) &lt;span class=&quot;error&quot;&gt;&amp;#91;bundlefile:na&amp;#93;&lt;/span&gt;&lt;br/&gt;
...&lt;br/&gt;
Is this &lt;a href=&quot;https://jira.opendaylight.org/browse/YANGTOOLS-129&quot; title=&quot;TypeDefinitionAwareCodec fails on type empty&quot; class=&quot;issue-link&quot; data-issue-key=&quot;YANGTOOLS-129&quot;&gt;&lt;del&gt;YANGTOOLS-129&lt;/del&gt;&lt;/a&gt;? I cannot tell if the issue is that yang tools is not providing a toString() in the generated source, or if the &apos;EnumCodecStringImpl&apos; in TypeDefinitionAwareCodec.java should be made smarter to invoke &apos;getIntValue()&apos; in this situation. If you think that should be the latter case, I may take a stab at &apos;fixing&apos;, under your wing, of course. &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.opendaylight.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;Thanks,&lt;/p&gt;

&lt;p&gt;&amp;#8211; flavio&lt;/p&gt;</description>
                <environment>&lt;p&gt;Operating System: All&lt;br/&gt;
Platform: PC&lt;/p&gt;</environment>
        <key id="22580">YANGTOOLS-160</key>
            <summary>String needs to be changed to Object (or Enum) in the method TypeDefinitionAwareCodec$EnumCodecStringImpl.serialize</summary>
                <type id="10104" iconUrl="https://jira.opendaylight.org/secure/viewavatar?size=xsmall&amp;avatarId=10303&amp;avatarType=issuetype">Bug</type>
                                                <status id="10004" iconUrl="https://jira.opendaylight.org/images/icons/status_generic.gif" description="">Verified</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="tpantelis">Tom Pantelis</assignee>
                                    <reporter username="flavio@flaviof.com">Flavio Fernandes</reporter>
                        <labels>
                    </labels>
                <created>Mon, 12 May 2014 15:15:18 +0000</created>
                <updated>Sun, 10 Apr 2022 18:35:05 +0000</updated>
                            <resolved>Wed, 21 May 2014 18:37:05 +0000</resolved>
                                                                        <due></due>
                            <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="42737" author="tpantelis" created="Tue, 13 May 2014 02:37:49 +0000"  >&lt;p&gt;This same issue occurs in the toaster example when invoking the make-toast RPC via restconf:&lt;/p&gt;

&lt;p&gt;HTTP Method =&amp;gt; POST&lt;br/&gt;
URL =&amp;gt; &lt;a href=&quot;http://localhost:8080/restconf/operations/toaster:make-toast&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://localhost:8080/restconf/operations/toaster:make-toast&lt;/a&gt; &lt;br/&gt;
Header =&amp;gt;   Content-Type: application/yang.data+json  &lt;br/&gt;
Body =&amp;gt;  &lt;br/&gt;
{&lt;br/&gt;
  &quot;input&quot; :&lt;/p&gt;
  {
     &quot;toaster:toasterDoneness&quot; : &quot;10&quot;,
     &quot;toaster:toasterToastType&quot;:&quot;wheat-bread&quot; 
  }
&lt;p&gt;}&lt;/p&gt;

&lt;p&gt;osgi&amp;gt; 2014-05-06 18:35:47.476 EDT &lt;span class=&quot;error&quot;&gt;&amp;#91;http-bio-8080-exec-1&amp;#93;&lt;/span&gt; ERROR o.o.c.sal.restconf.impl.RestCodec - ClassCastException was thrown when codec is invoked with parameter Up&lt;br/&gt;
java.lang.ClassCastException: org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster$ToasterStatus cannot be cast to java.lang.String&lt;br/&gt;
        at org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec$EnumCodecStringImpl.serialize(TypeDefinitionAwareCodec.java:512) ~&lt;span class=&quot;error&quot;&gt;&amp;#91;bundlefile:na&amp;#93;&lt;/span&gt;&lt;br/&gt;
        at org.opendaylight.controller.sal.restconf.impl.RestCodec$ObjectCodec.serialize(RestCodec.java:141) ~&lt;span class=&quot;error&quot;&gt;&amp;#91;bundlefile:na&amp;#93;&lt;/span&gt;&lt;/p&gt;</comment>
                            <comment id="42738" author="tpantelis" created="Tue, 13 May 2014 13:52:01 +0000"  >&lt;p&gt;In the Toaster example, the exception actually occurs on a GET to &lt;a href=&quot;http://localhost:8080/restconf/operational/toaster:toaster&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://localhost:8080/restconf/operational/toaster:toaster&lt;/a&gt; when attempting to convert the ToasterStatus enum value.&lt;/p&gt;

&lt;p&gt;The node value passed to EnumCodecStringImpl.serialize is an Enum type and not a String. RestCodec$ObjectCodec.serialize actually catches the exception, logs it and returns the original input value:&lt;/p&gt;

&lt;p&gt;  try &lt;/p&gt;
{           
      ....
      }
&lt;p&gt; else {&lt;br/&gt;
         TypeDefinitionAwareCodec&amp;lt;Object, ? extends TypeDefinition&amp;lt;&amp;gt;&amp;gt;&lt;br/&gt;
                  typeAwarecodec = TypeDefinitionAwareCodec.from(type);&lt;br/&gt;
         if (typeAwarecodec != null) &lt;/p&gt;
{
             return typeAwarecodec.serialize(input);
         }
&lt;p&gt; else &lt;/p&gt;
{
             logger.debug(&quot;Codec for type \&quot;&quot; + type.getQName().getLocalName()
                                + &quot;\&quot; is not implemented yet.&quot;);
             return null;
         }
&lt;p&gt;     }&lt;br/&gt;
  } &lt;br/&gt;
  catch (ClassCastException e) &lt;/p&gt;
{ // TODO remove this catch when
                                             // everyone use codecs
      logger.error(ClassCastException was thrown when codec is invoked with parameter &quot; + String.valueOf(input), e);
      return input;
  }

&lt;p&gt;JsonMapper.writeValueOfNodeByType then takes the returned ToasterStatus enum and &quot;toString&quot;&apos;s it via String.valueOf:&lt;/p&gt;

&lt;p&gt;  String value = String.valueOf(RestCodec.from(baseType, &lt;br/&gt;
                                      mountPoint).serialize(node.getValue()));&lt;/p&gt;

&lt;p&gt;So the exception is actually benign - RestCodec.from fails internally but the JsonMapper works correctly and the json data is returned correctly to the client.&lt;/p&gt;

&lt;p&gt;Changing EnumCodecStringImpl.serialize to take an Object should avoid the exception.&lt;/p&gt;</comment>
                            <comment id="42739" author="tpantelis" created="Wed, 14 May 2014 15:03:32 +0000"  >&lt;p&gt;The root cause of this issue is actually in the codec generated toDomStatic method:&lt;/p&gt;

&lt;p&gt; org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster$ToasterStatus getToasterStatus =                                                                                                                   &lt;br/&gt;
                                value.getToasterStatus();&lt;br/&gt;
    if(getToasterStatus != null) {&lt;br/&gt;
        org.opendaylight.yangtools.yang.common.QName _qname = &lt;br/&gt;
                                         org.opendaylight.yangtools.yang.common.QName.create(_resultName,&quot;toasterStatus&quot;);&lt;br/&gt;
        Object _propValue = getToasterStatus;&lt;br/&gt;
        if(_propValue != null) &lt;/p&gt;
{
            Object _domValue = java.util.Collections.singletonMap(_qname,_propValue);
            _childNodes.add(_domValue);
        }
&lt;p&gt;    }&lt;/p&gt;

&lt;p&gt;Instead of returning the enum, it should call:&lt;/p&gt;

&lt;p&gt;org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster$ToasterStatus$Codec$DOM.toDomValue&lt;/p&gt;</comment>
                            <comment id="42740" author="tpantelis" created="Tue, 20 May 2014 20:39:00 +0000"  >&lt;p&gt;This is issue was resolved by an upstream merge.&lt;/p&gt;</comment>
                            <comment id="42741" author="tony.tkacik@gmail.com" created="Wed, 21 May 2014 08:50:14 +0000"  >&lt;p&gt;Bugfix was: &lt;a href=&quot;https://git.opendaylight.org/gerrit/7019&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/7019&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="42742" author="flavio@flaviof.com" created="Wed, 21 May 2014 18:37:05 +0000"  >&lt;p&gt;Fixed as of:&lt;/p&gt;

&lt;p&gt;org.opendaylight.controller.version = 0.1&lt;br/&gt;
org.opendaylight.controller.build.scm.version = 0f1fdd655ea9dda3b0db24b6d1140fabcc10407d&lt;br/&gt;
org.opendaylight.controller.build.user = ffernand&lt;br/&gt;
org.opendaylight.controller.build.workspace = **********&lt;br/&gt;
org.opendaylight.controller.build.timestamp = 1400686832112&lt;br/&gt;
org.opendaylight.controller.build.machine = **********&lt;/p&gt;

&lt;p&gt;Still seeing:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://gist.github.com/0030bb1c3f3231846f3e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://gist.github.com/0030bb1c3f3231846f3e&lt;/a&gt;&lt;br/&gt;
which is tracked under &lt;br/&gt;
&lt;a href=&quot;https://bugs.opendaylight.org/show_bug.cgi?id=1027&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://bugs.opendaylight.org/show_bug.cgi?id=1027&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                            <customfield id="customfield_11400" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10208" key="com.atlassian.jira.plugin.system.customfieldtypes:textfield">
                        <customfieldname>External issue ID</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>990</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10201" key="com.atlassian.jira.plugin.system.customfieldtypes:url">
                        <customfieldname>External issue URL</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[https://bugs.opendaylight.org/show_bug.cgi?id=990]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10000" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|i026b0:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>