[
https://issues.apache.org/jira/browse/EDGENT-425?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16065511#comment-16065511
]
Dale LaBossiere commented on EDGENT-425:
----------------------------------------
This is an example of the issues noted in EDGENT-382.
Impl notes: as noted there, it's unclear where the responsibility for
addressing this lies.
To clarify what's happening in this case: IotpDevice's cmd handling function is
throwing.
That function is being called by map() on an implicitly isolated stream created
by Topology.events().
The net is the IotpDevice cmd handling ceases to occur after that exception
because the thread created by
Isolate to service (pull from) the queue is terminating due to the
map()/function throw.
The app is still running and still receiving cmd messages from WIoTP and these
continue to get added to the Isolate's unbounded queue until the application
runs out of memory.
> Handle JSON parsing exceptions gracefully when processing IoT commands
> ----------------------------------------------------------------------
>
> Key: EDGENT-425
> URL: https://issues.apache.org/jira/browse/EDGENT-425
> Project: Edgent
> Issue Type: Improvement
> Components: Connectors
> Reporter: Natasha D'Silva
> Priority: Minor
>
> I am running the IotpSensors application launched using the
> runiotpsensors.sh script. I noticed that if the JSON command payload is
> malformed, e.g.:
> "{'deviceId': 'rpi-2', 'typeId': 'R-PI-02', 'cmdId': 'display', 'd': '{"d":
> {"msg": "Hello Edgent!"}}'}"
> instead of
> {'deviceId': 'rpi-2', 'typeId': 'R-PI-02', 'cmdId': 'display', 'jsonString':
> '{"d": {"msg": "Hello Edgent!"}}'}
> Which is an example of a client sending bad data, then my Edgent application
> stops generating data altogether after throwing the exception below.
> It isn't a big deal in a small scenario because I can just restart my Edgent
> application, but it might be annoying on a real device.
> {code:java}
> Jun 26, 2017 5:17:59 PM org.apache.edgent.runtime.etiao.ThreadFactoryTracker
> trackedThreadUncaughtException
> SEVERE: Uncaught exception in thread pool-1-thread-27-IotpSensors
> java.lang.ClassCastException: com.google.gson.JsonPrimitive cannot be cast to
> com.google.gson.JsonObject
> at com.google.gson.JsonObject.getAsJsonObject(JsonObject.java:182)
> at
> org.apache.edgent.connectors.iotp.IotpDevice.lambda$commands$48c2e166$1(IotpDevice.java:348)
> at
> org.apache.edgent.function.Functions$ThreadSafeFunction.apply(Functions.java:127)
> at org.apache.edgent.oplet.functional.Map.accept(Map.java:45)
> at
> org.apache.edgent.runtime.etiao.SettableForwarder.accept(SettableForwarder.java:54)
> at org.apache.edgent.oplet.core.Pipe.submit(Pipe.java:65)
> at org.apache.edgent.oplet.functional.Filter.accept(Filter.java:37)
> at
> org.apache.edgent.runtime.etiao.SettableForwarder.accept(SettableForwarder.java:54)
> at org.apache.edgent.oplet.core.Pipe.submit(Pipe.java:65)
> at org.apache.edgent.oplet.plumbing.Isolate.run(Isolate.java:86)
> at
> org.apache.edgent.oplet.plumbing.Isolate.lambda$initialize$0(Isolate.java:64)
> at
> org.apache.edgent.runtime.etiao.ThreadFactoryTracker$2.run(ThreadFactoryTracker.java:87)
> at java.lang.Thread.run(Thread.java:745)
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)