Hello, It has been a quite long from Leshan.. got swapped to different tasks in the past few weeks, back to it again
J
While testing a client, I came across this issue ( Julien I think I did mention this issue to you in the testFest Dusseldorf, not sure if you still remember).
I think it’s a bug and it happen in the case of a client response contain OPAQUE Value, see the example below in
RED..
Use Case:
Location object, resource Velocity id “4” type is OPAQUE ..
MESSAGE = {"id":0,"resources":[{"id":0,"value":"test"},{"id":1,"value":"test"},{"id":2,"value":"test"},{"id":4,"value":[39,39]},{"id":5,"value":"1970-01-01T00:00:00Z"}]}
The code failed because of the if condition in
org.eclipse.leshan.standalone.servlet.json.LwM2mNodeDeserializer.java line 75…
}
else
if (object.has("value"))
{
// single value resource
/**
* Don’t you think if the type is Opaque
* It should check if if(object.get("value").isJsonArray())
* In this case it loop through and deserializeValue
*/
node = new
LwM2mResource(id, this.deserializeValue(object.get("value").getAsJsonPrimitive()));
// It’s an array not primitive that’s why the error thrown..
}
else
if (object.has("values"))
{
com.google.gson.JsonSyntaxException:
java.lang.IllegalStateException: This is not a JSON Primitive.
at com.google.gson.Gson.fromJson(Gson.java:815)
at com.google.gson.Gson.fromJson(Gson.java:868)
at com.google.gson.Gson$1.deserialize(Gson.java:126)
at
org.eclipse.leshan.standalone.servlet.json.LwM2mNodeDeserializer.deserialize(LwM2mNodeDeserializer.java:77)
at
org.eclipse.leshan.standalone.servlet.json.LwM2mNodeDeserializer.deserialize(LwM2mNodeDeserializer.java:50)
at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:58)
Thanks,
Nizar…!
This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either
whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
_______________________________________________
leshan-dev mailing list
leshan-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/leshan-dev