Merge pull request #8731 from ShvaykaD/bugfix/PROD-2116
fixed NPE in Flow output node when it used after split array msg node
This commit is contained in:
commit
e556afb511
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user