Merge pull request #11660 from YevhenBondarenko/fix/npe
fixed NPE in RuleNodeActorMessageProcessor
This commit is contained in:
commit
a4370d9b87
@ -43,6 +43,7 @@ import org.thingsboard.server.gen.transport.TransportProtos;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNodeId> {
|
public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNodeId> {
|
||||||
|
|
||||||
|
private static final String UNKNOWN_NAME = "Unknown";
|
||||||
private final String ruleChainName;
|
private final String ruleChainName;
|
||||||
private final TbApiUsageReportClient apiUsageClient;
|
private final TbApiUsageReportClient apiUsageClient;
|
||||||
private final DefaultTbContext defaultCtx;
|
private final DefaultTbContext defaultCtx;
|
||||||
@ -57,7 +58,7 @@ public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNod
|
|||||||
this.ruleChainName = ruleChainName;
|
this.ruleChainName = ruleChainName;
|
||||||
this.ruleNode = systemContext.getRuleChainService().findRuleNodeById(tenantId, entityId);
|
this.ruleNode = systemContext.getRuleChainService().findRuleNodeById(tenantId, entityId);
|
||||||
this.defaultCtx = new DefaultTbContext(systemContext, ruleChainName, new RuleNodeCtx(tenantId, parent, self, ruleNode));
|
this.defaultCtx = new DefaultTbContext(systemContext, ruleChainName, new RuleNodeCtx(tenantId, parent, self, ruleNode));
|
||||||
this.info = new RuleNodeInfo(ruleNodeId, ruleChainName, ruleNode != null ? ruleNode.getName() : "Unknown");
|
this.info = new RuleNodeInfo(ruleNodeId, ruleChainName, getName(ruleNode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -75,7 +76,7 @@ public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNod
|
|||||||
public void onUpdate(TbActorCtx context) throws Exception {
|
public void onUpdate(TbActorCtx context) throws Exception {
|
||||||
RuleNode newRuleNode = systemContext.getRuleChainService().findRuleNodeById(tenantId, entityId);
|
RuleNode newRuleNode = systemContext.getRuleChainService().findRuleNodeById(tenantId, entityId);
|
||||||
if (isMyNodePartition(newRuleNode)) {
|
if (isMyNodePartition(newRuleNode)) {
|
||||||
this.info = new RuleNodeInfo(entityId, ruleChainName, newRuleNode != null ? newRuleNode.getName() : "Unknown");
|
this.info = new RuleNodeInfo(entityId, ruleChainName, getName(newRuleNode));
|
||||||
boolean restartRequired = state != ComponentLifecycleState.ACTIVE ||
|
boolean restartRequired = state != ComponentLifecycleState.ACTIVE ||
|
||||||
!(ruleNode.getType().equals(newRuleNode.getType()) && ruleNode.getConfiguration().equals(newRuleNode.getConfiguration()));
|
!(ruleNode.getType().equals(newRuleNode.getType()) && ruleNode.getConfiguration().equals(newRuleNode.getConfiguration()));
|
||||||
this.ruleNode = newRuleNode;
|
this.ruleNode = newRuleNode;
|
||||||
@ -167,7 +168,11 @@ public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNod
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getComponentName() {
|
public String getComponentName() {
|
||||||
return ruleNode.getName();
|
return getName(ruleNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getName(RuleNode ruleNode) {
|
||||||
|
return ruleNode != null ? ruleNode.getName() : UNKNOWN_NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TbNode initComponent(RuleNode ruleNode) throws Exception {
|
private TbNode initComponent(RuleNode ruleNode) throws Exception {
|
||||||
|
|||||||
@ -240,7 +240,7 @@ public final class TbActorMailbox implements TbActorCtx {
|
|||||||
highPriorityMsgs.forEach(msg -> msg.onTbActorStopped(stopReason));
|
highPriorityMsgs.forEach(msg -> msg.onTbActorStopped(stopReason));
|
||||||
normalPriorityMsgs.forEach(msg -> msg.onTbActorStopped(stopReason));
|
normalPriorityMsgs.forEach(msg -> msg.onTbActorStopped(stopReason));
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.warn("[{}] Failed to destroy actor: {}", selfId, t);
|
log.warn("[{}] Failed to destroy actor: ", selfId, t);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user