Skip to content

Commit

Permalink
Merge pull request #11660 from YevhenBondarenko/fix/npe
Browse files Browse the repository at this point in the history
fixed NPE in RuleNodeActorMessageProcessor
  • Loading branch information
ViacheslavKlimov authored Sep 16, 2024
2 parents 8230a8d + 0c4e06a commit a4370d9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
@Slf4j
public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNodeId> {

private static final String UNKNOWN_NAME = "Unknown";
private final String ruleChainName;
private final TbApiUsageReportClient apiUsageClient;
private final DefaultTbContext defaultCtx;
Expand All @@ -57,7 +58,7 @@ public class RuleNodeActorMessageProcessor extends ComponentMsgProcessor<RuleNod
this.ruleChainName = ruleChainName;
this.ruleNode = systemContext.getRuleChainService().findRuleNodeById(tenantId, entityId);
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
Expand All @@ -75,7 +76,7 @@ public void start(TbActorCtx context) throws Exception {
public void onUpdate(TbActorCtx context) throws Exception {
RuleNode newRuleNode = systemContext.getRuleChainService().findRuleNodeById(tenantId, entityId);
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 ||
!(ruleNode.getType().equals(newRuleNode.getType()) && ruleNode.getConfiguration().equals(newRuleNode.getConfiguration()));
this.ruleNode = newRuleNode;
Expand Down Expand Up @@ -167,7 +168,11 @@ void onRuleChainToRuleNodeMsg(RuleChainToRuleNodeMsg msg) throws Exception {

@Override
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public void destroy(Throwable cause) {
highPriorityMsgs.forEach(msg -> msg.onTbActorStopped(stopReason));
normalPriorityMsgs.forEach(msg -> msg.onTbActorStopped(stopReason));
} catch (Throwable t) {
log.warn("[{}] Failed to destroy actor: {}", selfId, t);
log.warn("[{}] Failed to destroy actor: ", selfId, t);
}
});
}
Expand Down

0 comments on commit a4370d9

Please sign in to comment.