Merge pull request #7791 from YuriyLytvynchuk/bugfix/split_array_node

[3.5] Bugfix: Node 'split array msg'. Empty array
This commit is contained in:
Andrew Shvayka 2022-12-15 12:43:46 +02:00 committed by GitHub
commit 3c84ad5072
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,7 @@ 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. If the msg data is not a JSON object returns the "
nodeDetails = "Split the array fetched from the msg body. If the msg data is not a JSON array returns the "
+ "incoming message as outbound message with <code>Failure</code> chain, otherwise returns "
+ "inner objects of the extracted array as separate messages via <code>Success</code> chain.",
uiResources = {"static/rulenode/rulenode-core-config.js"},
@ -61,7 +61,9 @@ public class TbSplitArrayMsgNode implements TbNode {
JsonNode jsonNode = JacksonUtil.toJsonNode(msg.getData());
if (jsonNode.isArray()) {
ArrayNode data = (ArrayNode) jsonNode;
if (data.size() == 1) {
if (data.isEmpty()) {
ctx.ack(msg);
} else if (data.size() == 1) {
ctx.tellSuccess(TbMsg.transformMsg(msg, msg.getType(), msg.getOriginator(), msg.getMetaData(), JacksonUtil.toString(data.get(0))));
} else {
TbMsgCallbackWrapper wrapper = new MultipleTbMsgsCallbackWrapper(data.size(), new TbMsgCallback() {