Details
-
Bug
-
Status: Verified
-
Resolution: Done
-
None
-
None
-
None
-
None
-
Operating System: All
Platform: PC
-
990
Description
While following the md-sal tutorial on ping: https://wiki.opendaylight.org/view/Ping
I see the exception below when exercising the RPC rest call as shown:
http://localhost:8080/restconf/operations/ping:send-echo
With the following headers:
Content-Type: application/yang.operation+json
Cache-Control: no-cache
and the data set to raw Json encoded data (for POSTMAN at least)
{ "input" :
}
—
From: Tom Pantelis <tompantelis@gmail.com>
Subject: Re: 2014-05-10 16:21:48.964 EDT [http-bio-8080-exec-7] 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
Date: May 12, 2014 at 11:06:04 AM EDT
To: Flavio Fernandes <ffernand@redhat.com>
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.
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 YANGTOOLS-129.
On Mon, May 12, 2014 at 9:21 AM, Flavio Fernandes <ffernand@redhat.com> wrote:
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
not there yet.
Do you know who would be the most familiar with that code? I’m trying to reach Tony T. but no answer yet.
Maybe he is busy at the OpenStack Summit.
Chhers,
— flavio
On May 11, 2014, at 12:56 PM, Tom Pantelis <tompantelis@gmail.com> wrote:
Flavio,
I'm not familiar with this code but it looks like the ex occurs when invoking the EnumCodecStringImp.serialize method because the JVM can'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.
Tom
On Sat, May 10, 2014 at 6:17 PM, Flavio Fernandes <ffernand@redhat.com> wrote:
Hi Tom,
While doing the MD-SAL tutorial on ping ( https://wiki.opendaylight.org/view/Ping ), I hit an exception that looks like this:
...
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_51]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51]
2014-05-10 16:21:48.964 EDT [http-bio-8080-exec-7] 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
at org.opendaylight.yangtools.yang.data.impl.codec.TypeDefinitionAwareCodec$EnumCodecStringImpl.serialize(TypeDefinitionAwareCodec.java:512) ~[bundlefile:na]
at org.opendaylight.controller.sal.restconf.impl.RestCodec$ObjectCodec.serialize(RestCodec.java:141) ~[bundlefile:na]
at org.opendaylight.controller.sal.rest.impl.JsonMapper.writeValueOfNodeByType(JsonMapper.java:240) [bundlefile:na]
at org.opendaylight.controller.sal.rest.impl.JsonMapper.writeLeaf(JsonMapper.java:193) [bundlefile:na]
...
Is this YANGTOOLS-129? I cannot tell if the issue is that yang tools is not providing a toString() in the generated source, or if the 'EnumCodecStringImpl' in TypeDefinitionAwareCodec.java should be made smarter to invoke 'getIntValue()' in this situation. If you think that should be the latter case, I may take a stab at 'fixing', under your wing, of course. ![]()
Thanks,
– flavio