Browse Source
Merge pull request #8731 from ShvaykaD/bugfix/PROD-2116
fixed NPE in Flow output node when it used after split array msg node
pull/8759/head
Andrew Shvayka
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
9 additions and
3 deletions
-
common/message/src/main/java/org/thingsboard/server/common/msg/TbMsgProcessingCtx.java
-
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNode.java
-
rule-engine/rule-engine-components/src/test/java/org/thingsboard/rule/engine/transform/TbSplitArrayMsgNodeTest.java
|
|
|
@ -64,7 +64,10 @@ public final class TbMsgProcessingCtx implements Serializable { |
|
|
|
} |
|
|
|
|
|
|
|
public TbMsgProcessingStackItem pop() { |
|
|
|
return !stack.isEmpty() ? stack.removeLast() : null; |
|
|
|
if (stack == null || stack.isEmpty()) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
return stack.removeLast(); |
|
|
|
} |
|
|
|
|
|
|
|
public static TbMsgProcessingCtx fromProto(MsgProtos.TbMsgProcessingCtxProto ctx) { |
|
|
|
|
|
|
|
@ -77,8 +77,10 @@ public class TbSplitArrayMsgNode implements TbNode { |
|
|
|
ctx.tellFailure(msg, e); |
|
|
|
} |
|
|
|
}); |
|
|
|
data.forEach(msgNode -> ctx.enqueueForTellNext(TbMsg.newMsg(msg.getQueueName(), msg.getType(), msg.getOriginator(), msg.getMetaData(), JacksonUtil.toString(msgNode)), |
|
|
|
TbRelationTypes.SUCCESS, wrapper::onSuccess, wrapper::onFailure)); |
|
|
|
data.forEach(msgNode -> { |
|
|
|
TbMsg outMsg = TbMsg.transformMsg(msg, msg.getType(), msg.getOriginator(), msg.getMetaData(), JacksonUtil.toString(msgNode)); |
|
|
|
ctx.enqueueForTellNext(outMsg, TbRelationTypes.SUCCESS, wrapper::onSuccess, wrapper::onFailure); |
|
|
|
}); |
|
|
|
} |
|
|
|
} else { |
|
|
|
ctx.tellFailure(msg, new RuntimeException("Msg data is not a JSON Array!")); |
|
|
|
|
|
|
|
@ -96,6 +96,7 @@ public class TbSplitArrayMsgNodeTest { |
|
|
|
ArgumentCaptor<TbMsg> newMsgCaptor = ArgumentCaptor.forClass(TbMsg.class); |
|
|
|
ArgumentCaptor<Exception> exceptionCaptor = ArgumentCaptor.forClass(Exception.class); |
|
|
|
verify(ctx, never()).tellSuccess(any()); |
|
|
|
verify(ctx, never()).enqueueForTellNext(any(), anyString(), any(), any()); |
|
|
|
verify(ctx, times(1)).tellFailure(newMsgCaptor.capture(), exceptionCaptor.capture()); |
|
|
|
|
|
|
|
assertThat(exceptionCaptor.getValue()).isInstanceOf(RuntimeException.class); |
|
|
|
|