mirror of
https://gitee.com/dromara/liteFlow.git
synced 2026-05-14 12:12:08 +08:00
bug #I6Y300 修复可能IdGeneratorHolder 存在的NPE异常
This commit is contained in:
@@ -71,8 +71,9 @@ public class FlowExecutor {
|
||||
|
||||
/**
|
||||
* FlowExecutor的初始化化方式,主要用于parse规则文件
|
||||
* isStart表示是否是系统启动阶段,启动阶段要做额外的事情,而因为reload所调用的init就不用做
|
||||
*/
|
||||
public void init(boolean hook) {
|
||||
public void init(boolean isStart) {
|
||||
if (ObjectUtil.isNull(liteflowConfig)) {
|
||||
throw new ConfigErrorException("config error, please check liteflow config property");
|
||||
}
|
||||
@@ -82,8 +83,10 @@ public class FlowExecutor {
|
||||
// 在非spring体系下是一个空实现,等于不做此步骤
|
||||
ContextCmpInitHolder.loadContextCmpInit().initCmp();
|
||||
|
||||
// 进行id生成器的初始化
|
||||
IdGeneratorHolder.init();
|
||||
if (isStart){
|
||||
// 进行id生成器的初始化
|
||||
IdGeneratorHolder.init();
|
||||
}
|
||||
|
||||
String ruleSource = liteflowConfig.getRuleSource();
|
||||
if (StrUtil.isBlank(ruleSource)) {
|
||||
@@ -191,7 +194,7 @@ public class FlowExecutor {
|
||||
}
|
||||
|
||||
// 执行钩子
|
||||
if (hook) {
|
||||
if (isStart) {
|
||||
FlowInitHook.executeHook();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.yomahub.liteflow.flow.id;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.yomahub.liteflow.exception.RequestIdGeneratorException;
|
||||
import com.yomahub.liteflow.property.LiteflowConfig;
|
||||
@@ -44,6 +45,9 @@ public class IdGeneratorHolder {
|
||||
}
|
||||
|
||||
public String generate() {
|
||||
if (ObjectUtil.isNull(requestIdGenerator)){
|
||||
init();
|
||||
}
|
||||
return requestIdGenerator.generate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user