Refactor: add check to ensure msg data is always object

This commit is contained in:
Dmytro Skarzhynets 2023-04-17 15:45:16 +03:00
parent 913c6b60e2
commit acac0af2d1

View File

@ -77,6 +77,9 @@ public class CalculateDeltaNode implements TbNode {
public void onMsg(TbContext ctx, TbMsg msg) {
if (msg.getType().equals(SessionMsgType.POST_TELEMETRY_REQUEST.name())) {
JsonNode json = JacksonUtil.toJsonNode(msg.getData());
if (!json.isObject()) {
throw new IllegalArgumentException("Message body is not an object!");
}
String inputKey = config.getInputValueKey();
if (json.has(inputKey)) {
DonAsynchron.withCallback(getLastValue(msg.getOriginator()),