From 058562a5aefa166231399129ce7b2bd9bdb7fd65 Mon Sep 17 00:00:00 2001 From: yangqicheng Date: Thu, 26 Sep 2024 13:40:09 +0800 Subject: [PATCH] =?UTF-8?q?REQ-2924-=E6=96=B0=E5=BB=BAjob=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E5=AE=9E=E4=BE=8B=E4=B8=8D=E5=AD=98=E5=9C=A8=EF=BC=8C?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E9=99=8D=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflow/core/engine/cmd/CustomCommandContext.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/cmd/CustomCommandContext.java b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/cmd/CustomCommandContext.java index 1e70e2247..5af132216 100644 --- a/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/cmd/CustomCommandContext.java +++ b/workflow-engine-core/src/main/java/cn/axzo/workflow/core/engine/cmd/CustomCommandContext.java @@ -1,12 +1,16 @@ package cn.axzo.workflow.core.engine.cmd; import cn.axzo.workflow.core.common.exception.WorkflowEngineException; +import org.apache.ibatis.exceptions.PersistenceException; import org.flowable.common.engine.api.FlowableException; import org.flowable.common.engine.api.FlowableOptimisticLockingException; import org.flowable.common.engine.impl.interceptor.Command; import org.flowable.common.engine.impl.interceptor.CommandContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; + +import java.util.Arrays; /** * 对 CommandContext 中的 WorkflowEngineException 进行日志降级 @@ -17,6 +21,8 @@ import org.slf4j.LoggerFactory; public class CustomCommandContext extends CommandContext { private static final Logger LOGGER = LoggerFactory.getLogger(CustomCommandContext.class); + private static final String[] PERSISTENCE_EXCEPTION_WARN_MESSAGE = new String[]{"act_ru_job"}; + public CustomCommandContext(Command command) { super(command); } @@ -36,6 +42,10 @@ public class CustomCommandContext extends CommandContext { LOGGER.info("Error while closing command context", exception); } else if (exception instanceof WorkflowEngineException) { LOGGER.warn("Workflow error while closing command context", exception); + } else if (exception instanceof PersistenceException && + StringUtils.hasText(exception.getMessage()) && + Arrays.stream(PERSISTENCE_EXCEPTION_WARN_MESSAGE).anyMatch(m -> exception.getMessage().contains(m))) { + LOGGER.warn("persistence error while closing command context", exception); } else { LOGGER.error("Error while closing command context", exception);