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);