From 07e3fd703eb9d250cb3681e6edfc8683dce5bd8e Mon Sep 17 00:00:00 2001 From: "everywhere.z" Date: Wed, 3 May 2023 21:36:32 +0800 Subject: [PATCH] =?UTF-8?q?bug=20#I6Y300=20=E4=BF=AE=E5=A4=8D=E5=8F=AF?= =?UTF-8?q?=E8=83=BDIdGeneratorHolder=20=E5=AD=98=E5=9C=A8=E7=9A=84NPE?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yomahub/liteflow/core/FlowExecutor.java | 11 +++++++---- .../yomahub/liteflow/flow/id/IdGeneratorHolder.java | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java index 31dba4b70..34695ad5d 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/core/FlowExecutor.java @@ -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(); } diff --git a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/id/IdGeneratorHolder.java b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/id/IdGeneratorHolder.java index a5ef66665..31c4e6d64 100644 --- a/liteflow-core/src/main/java/com/yomahub/liteflow/flow/id/IdGeneratorHolder.java +++ b/liteflow-core/src/main/java/com/yomahub/liteflow/flow/id/IdGeneratorHolder.java @@ -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(); }