diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNode.java
index d6dbc88776..1c682fbf7c 100644
--- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNode.java
+++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNode.java
@@ -39,9 +39,9 @@ import java.util.concurrent.ExecutionException;
name = "split array msg",
configClazz = EmptyNodeConfiguration.class,
nodeDescription = "Split array message into several msgs",
- nodeDetails = "Split the array fetched from the msg body. Returns inner objects of the extracted array as "
- + "separate messages via Success chain. If msg data is not a JSON array, "
- + "the incoming message is returned",
+ nodeDetails = "Split the array fetched from the msg body. If the msg data is not a JSON object returns the "
+ + "incoming message as outbound message with Failure chain, otherwise returns "
+ + "inner objects of the extracted array as separate messages via Success chain.",
icon = "content_copy",
configDirective = "tbNodeEmptyConfig"
)
@@ -72,7 +72,7 @@ public class TbSplitArrayMsgNode implements TbNode {
}
}
} else {
- ctx.tellSuccess(msg);
+ ctx.tellFailure(msg, new RuntimeException("Msg data is not a JSON Array!"));
}
}
diff --git a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNodeTest.java b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNodeTest.java
index a54efad4aa..17bfd1663c 100644
--- a/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNodeTest.java
+++ b/rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNodeTest.java
@@ -94,15 +94,18 @@ public class TbSplitArrayMsgNodeTest {
}
@Test
- void givenNoArrayMsg_whenOnMsg_thenVerifyOutput() throws Exception {
+ void givenNoArrayMsg_whenOnMsg_thenFailure() throws Exception {
String data = "{\"Attribute_1\":22.5,\"Attribute_2\":10.3}";
JsonNode dataNode = JacksonUtil.toJsonNode(data);
TbMsg msg = getTbMsg(deviceId, dataNode.toString());
node.onMsg(ctx, msg);
ArgumentCaptor newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class);
- verify(ctx, times(1)).tellSuccess(newMsgCaptor.capture());
- verify(ctx, never()).tellFailure(any(), any());
+ ArgumentCaptor exceptionCaptor = ArgumentCaptor.forClass(Exception.class);
+ verify(ctx, never()).tellSuccess(any());
+ verify(ctx, times(1)).tellFailure(newMsgCaptor.capture(), exceptionCaptor.capture());
+
+ assertThat(exceptionCaptor.getValue()).isInstanceOf(RuntimeException.class);
TbMsg newMsg = newMsgCaptor.getValue();
assertThat(newMsg).isNotNull();