Commit dc7763ef0b126dc561b2bdbf2d9f60c2b671f16f

Authored by YunaiV
1 parent 49c857c8

fix:【BPM 工作流】BpmTaskCandidateExpressionStrategy 在 PropertyNotFoundException 不存在时,频繁打 warn 日志

yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignLeaderExpression.java
@@ -24,6 +24,7 @@ import static java.util.Collections.emptySet; @@ -24,6 +24,7 @@ import static java.util.Collections.emptySet;
24 * @author 芋道源码 24 * @author 芋道源码
25 */ 25 */
26 @Component 26 @Component
  27 +@Deprecated // 仅仅是表达式的示例,建议使用 BpmTaskCandidateStartUserDeptLeaderStrategy 替代
27 public class BpmTaskAssignLeaderExpression { 28 public class BpmTaskAssignLeaderExpression {
28 29
29 @Resource 30 @Resource
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/expression/BpmTaskAssignStartUserExpression.java
@@ -16,6 +16,7 @@ import java.util.Set; @@ -16,6 +16,7 @@ import java.util.Set;
16 * @author 芋道源码 16 * @author 芋道源码
17 */ 17 */
18 @Component 18 @Component
  19 +@Deprecated // 仅仅是表达式的示例,建议使用 BpmTaskCandidateStartUserStrategy 替代
19 public class BpmTaskAssignStartUserExpression { 20 public class BpmTaskAssignStartUserExpression {
20 21
21 @Resource 22 @Resource
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/candidate/strategy/other/BpmTaskCandidateExpressionStrategy.java
@@ -8,6 +8,7 @@ import com.google.common.collect.Sets; @@ -8,6 +8,7 @@ import com.google.common.collect.Sets;
8 import lombok.extern.slf4j.Slf4j; 8 import lombok.extern.slf4j.Slf4j;
9 import org.flowable.bpmn.model.BpmnModel; 9 import org.flowable.bpmn.model.BpmnModel;
10 import org.flowable.common.engine.api.FlowableException; 10 import org.flowable.common.engine.api.FlowableException;
  11 +import org.flowable.common.engine.impl.javax.el.PropertyNotFoundException;
11 import org.flowable.engine.delegate.DelegateExecution; 12 import org.flowable.engine.delegate.DelegateExecution;
12 import org.springframework.stereotype.Component; 13 import org.springframework.stereotype.Component;
13 14
@@ -48,10 +49,12 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat @@ -48,10 +49,12 @@ public class BpmTaskCandidateExpressionStrategy implements BpmTaskCandidateStrat
48 Object result = FlowableUtils.getExpressionValue(variables, param); 49 Object result = FlowableUtils.getExpressionValue(variables, param);
49 return CollectionUtils.toLinkedHashSet(Long.class, result); 50 return CollectionUtils.toLinkedHashSet(Long.class, result);
50 } catch (FlowableException ex) { 51 } catch (FlowableException ex) {
51 - // 预测未运行的节点时候,表达式如果包含 execution 或者不存在的流程变量会抛异常,  
52 - log.warn("[calculateUsersByActivity][表达式({}) 变量({}) 解析报错", param, variables, ex);  
53 - // 不能预测候选人,返回空列表, 避免流程无法进行  
54 - return Sets.newHashSet(); 52 + // 预测未运行的节点时候,表达式如果包含 execution 或者不存在的流程变量会抛异常,此时忽略该异常!相当于说,不做流程预测!!!
  53 + if (ex.getCause() != null && ex.getCause() instanceof PropertyNotFoundException) {
  54 + return Sets.newHashSet();
  55 + }
  56 + log.error("[calculateUsersByActivity][表达式({}) 变量({}) 解析报错", param, variables, ex);
  57 + throw ex;
55 } 58 }
56 } 59 }
57 60