Skip to content

Commit 61d86aa

Browse files
committed
fix processNodes NPE
1 parent 40d0046 commit 61d86aa

9 files changed

Lines changed: 21 additions & 28 deletions

File tree

flow-engine-framework/src/main/java/com/codingapi/flow/domain/DelayTaskManager.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.codingapi.flow.domain;
22

3+
import com.codingapi.flow.cache.FlowOperatorLocalThreadCache;
34
import com.codingapi.flow.service.impl.FlowDelayTriggerService;
45
import com.codingapi.flow.session.IRepositoryHolder;
56
import lombok.Getter;
@@ -30,7 +31,7 @@ public void start(IRepositoryHolder repositoryHolder) {
3031
List<DelayTask> delayTasks = repositoryHolder.findDelayTasks();
3132
if (delayTasks != null && !delayTasks.isEmpty()) {
3233
for (DelayTask delayTask : delayTasks) {
33-
this.addTask(delayTask,repositoryHolder);
34+
this.addTask(delayTask, repositoryHolder);
3435
}
3536
}
3637
System.out.println("flow delay task started");
@@ -52,9 +53,9 @@ public void close() {
5253
/**
5354
* 添加任务队列
5455
*/
55-
public void addTask(DelayTask task,IRepositoryHolder repositoryHolder) {
56+
public void addTask(DelayTask task, IRepositoryHolder repositoryHolder) {
5657
repositoryHolder.saveDelayTask(task);
57-
this.delayJobs.add(new DelayJob(task,repositoryHolder));
58+
this.delayJobs.add(new DelayJob(task, repositoryHolder));
5859
}
5960

6061
/**
@@ -64,7 +65,7 @@ private static class DelayJob {
6465
private final DelayTask task;
6566
private final Timer timer;
6667

67-
public DelayJob(DelayTask task,IRepositoryHolder repositoryHolder) {
68+
public DelayJob(DelayTask task, IRepositoryHolder repositoryHolder) {
6869
this.task = task;
6970
this.timer = new Timer();
7071
this.start(repositoryHolder);
@@ -78,11 +79,9 @@ private void start(IRepositoryHolder repositoryHolder) {
7879
this.timer.schedule(new TimerTask() {
7980
@Override
8081
public void run() {
81-
82+
FlowOperatorLocalThreadCache.getInstance().clear();
8283
FlowDelayTriggerService flowDelayTriggerService = repositoryHolder.createDelayTriggerService(task);
83-
8484
flowDelayTriggerService.trigger();
85-
8685
repositoryHolder.deleteDelayTask(task);
8786
}
8887
}, new Date(task.getTriggerTime()));

flow-engine-framework/src/main/java/com/codingapi/flow/service/FlowService.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.codingapi.flow.service;
22

3+
import com.codingapi.flow.cache.FlowOperatorLocalThreadCache;
34
import com.codingapi.flow.pojo.request.*;
45
import com.codingapi.flow.pojo.response.ActionResponse;
56
import com.codingapi.flow.pojo.response.FlowContent;
@@ -26,22 +27,26 @@ public FlowService(IRepositoryHolder repositoryHolder) {
2627

2728
/**
2829
* 流程详情
30+
*
2931
* @param request 流程详情请求
3032
* @return 流程详情
3133
*/
3234
public FlowContent detail(FlowDetailRequest request) {
33-
FlowDetailService flowDetailService = new FlowDetailService(request,this.repositoryHolder);
35+
FlowOperatorLocalThreadCache.getInstance().clear();
36+
FlowDetailService flowDetailService = new FlowDetailService(request, this.repositoryHolder);
3437
return flowDetailService.detail();
3538
}
3639

3740

3841
/**
3942
* 流程节点记录
43+
*
4044
* @param request 流程节点记录请求
4145
* @return 流程节点记录列表
4246
*/
4347
public List<ProcessNode> processNodes(FlowProcessNodeRequest request) {
44-
FlowProcessNodeService flowProcessNodeService = new FlowProcessNodeService(request,this.repositoryHolder);
48+
FlowOperatorLocalThreadCache.getInstance().clear();
49+
FlowProcessNodeService flowProcessNodeService = new FlowProcessNodeService(request, this.repositoryHolder);
4550
return flowProcessNodeService.processNodes();
4651
}
4752

@@ -52,7 +57,8 @@ public List<ProcessNode> processNodes(FlowProcessNodeRequest request) {
5257
* @return 创建的流程id
5358
*/
5459
public long create(FlowCreateRequest request) {
55-
FlowCreateService flowCreateService = new FlowCreateService(request,this.repositoryHolder);
60+
FlowOperatorLocalThreadCache.getInstance().clear();
61+
FlowCreateService flowCreateService = new FlowCreateService(request, this.repositoryHolder);
5662
return flowCreateService.create();
5763
}
5864

@@ -62,7 +68,8 @@ public long create(FlowCreateRequest request) {
6268
* @param request 审批请求
6369
*/
6470
public ActionResponse action(FlowActionRequest request) {
65-
FlowActionService flowActionService = new FlowActionService(request,this.repositoryHolder);
71+
FlowOperatorLocalThreadCache.getInstance().clear();
72+
FlowActionService flowActionService = new FlowActionService(request, this.repositoryHolder);
6673
return flowActionService.action();
6774
}
6875

@@ -72,7 +79,8 @@ public ActionResponse action(FlowActionRequest request) {
7279
* @param request 撤销请求
7380
*/
7481
public void revoke(FlowRevokeRequest request) {
75-
FlowRevokeService flowRevokeService = new FlowRevokeService(request,this.repositoryHolder);
82+
FlowOperatorLocalThreadCache.getInstance().clear();
83+
FlowRevokeService flowRevokeService = new FlowRevokeService(request, this.repositoryHolder);
7684
flowRevokeService.revoke();
7785
}
7886

@@ -81,7 +89,8 @@ public void revoke(FlowRevokeRequest request) {
8189
* 催办
8290
*/
8391
public void urge(FlowUrgeRequest request) {
84-
FlowUrgeService flowUrgeService = new FlowUrgeService(request,this.repositoryHolder);
92+
FlowOperatorLocalThreadCache.getInstance().clear();
93+
FlowUrgeService flowUrgeService = new FlowUrgeService(request, this.repositoryHolder);
8594
flowUrgeService.urge();
8695
}
8796
}

flow-engine-framework/src/main/java/com/codingapi/flow/service/impl/FlowActionService.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.codingapi.flow.service.impl;
22

33
import com.codingapi.flow.action.IFlowAction;
4-
import com.codingapi.flow.cache.FlowOperatorLocalThreadCache;
54
import com.codingapi.flow.context.ActionResponseContext;
65
import com.codingapi.flow.exception.FlowNotFoundException;
76
import com.codingapi.flow.exception.FlowStateException;
@@ -42,12 +41,9 @@ public FlowActionService(FlowActionRequest request,IRepositoryHolder repositoryH
4241
}
4342

4443
public ActionResponse action() {
45-
46-
FlowOperatorLocalThreadCache.getInstance().clear();
4744
ActionResponseContext.getInstance().clear();
4845
request.verify();
4946

50-
5147
// 验证当前用户
5248
IFlowOperator currentOperator = flowOperatorGateway.get(request.getAdvice().getOperatorId());
5349
if (currentOperator == null) {

flow-engine-framework/src/main/java/com/codingapi/flow/service/impl/FlowCreateService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.codingapi.flow.service.impl;
22

33
import com.codingapi.flow.action.IFlowAction;
4-
import com.codingapi.flow.cache.FlowOperatorLocalThreadCache;
54
import com.codingapi.flow.event.FlowRecordStartEvent;
65
import com.codingapi.flow.event.FlowRecordTodoEvent;
76
import com.codingapi.flow.event.IFlowEvent;
@@ -43,7 +42,6 @@ public FlowCreateService(FlowCreateRequest request,IRepositoryHolder repositoryH
4342
}
4443

4544
public long create() {
46-
FlowOperatorLocalThreadCache.getInstance().clear();
4745
request.verify();
4846
Workflow workflow = workflowService.getWorkflow(request.getWorkId());
4947
if (workflow == null) {

flow-engine-framework/src/main/java/com/codingapi/flow/service/impl/FlowDelayTriggerService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public FlowDelayTriggerService(DelayTask delayTask, IRepositoryHolder repository
4343
* 延期任务触发执行
4444
*/
4545
public void trigger() {
46-
FlowOperatorLocalThreadCache.getInstance().clear();
4746
FlowRecord flowRecord = flowRecordService.getFlowRecord(delayTask.getCurrentRecordId());
4847
if (flowRecord == null) {
4948
throw FlowNotFoundException.record(delayTask.getCurrentRecordId());

flow-engine-framework/src/main/java/com/codingapi/flow/service/impl/FlowDetailService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.codingapi.flow.service.impl;
22

3-
import com.codingapi.flow.cache.FlowOperatorLocalThreadCache;
43
import com.codingapi.flow.exception.FlowNotFoundException;
54
import com.codingapi.flow.node.IFlowNode;
65
import com.codingapi.flow.operator.IFlowOperator;
@@ -35,7 +34,6 @@ public FlowDetailService(FlowDetailRequest request, IRepositoryHolder repository
3534
}
3635

3736
public FlowContent detail() {
38-
FlowOperatorLocalThreadCache.getInstance().clear();
3937
if (this.request.isCreateWorkflow()) {
4038
Workflow workflow = workflowService.getWorkflow(this.request.getId());
4139
if (workflow == null) {

flow-engine-framework/src/main/java/com/codingapi/flow/service/impl/FlowProcessNodeService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.codingapi.flow.action.IFlowAction;
44
import com.codingapi.flow.action.actions.PassAction;
5-
import com.codingapi.flow.cache.FlowOperatorLocalThreadCache;
65
import com.codingapi.flow.exception.FlowNotFoundException;
76
import com.codingapi.flow.form.FormData;
87
import com.codingapi.flow.manager.ActionManager;
@@ -119,7 +118,6 @@ private void fetchFlowRecordOperatorList() {
119118
}
120119

121120
public List<ProcessNode> processNodes() {
122-
FlowOperatorLocalThreadCache.getInstance().clear();
123121
// load history data
124122
if (this.flowRecord != null) {
125123
this.loadHistoryData();

flow-engine-framework/src/main/java/com/codingapi/flow/service/impl/FlowRevokeService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.codingapi.flow.service.impl;
22

3-
import com.codingapi.flow.cache.FlowOperatorLocalThreadCache;
43
import com.codingapi.flow.event.FlowRecordTodoEvent;
54
import com.codingapi.flow.event.IFlowEvent;
65
import com.codingapi.flow.exception.FlowNotFoundException;
@@ -39,7 +38,6 @@ public FlowRevokeService(FlowRevokeRequest request,IRepositoryHolder repositoryH
3938
}
4039

4140
public void revoke() {
42-
FlowOperatorLocalThreadCache.getInstance().clear();
4341
request.verify();
4442
// 验证当前用户
4543
FlowRecord currentRecord = flowRecordService.getFlowRecord(request.getRecordId());

flow-engine-framework/src/main/java/com/codingapi/flow/service/impl/FlowUrgeService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.codingapi.flow.service.impl;
22

3-
import com.codingapi.flow.cache.FlowOperatorLocalThreadCache;
43
import com.codingapi.flow.domain.UrgeInterval;
54
import com.codingapi.flow.event.FlowRecordUrgeEvent;
65
import com.codingapi.flow.event.IFlowEvent;
@@ -46,7 +45,6 @@ public FlowUrgeService(FlowUrgeRequest request,IRepositoryHolder repositoryHolde
4645
* 催办
4746
*/
4847
public void urge() {
49-
FlowOperatorLocalThreadCache.getInstance().clear();
5048
request.verify();
5149
// 验证当前用户
5250
FlowRecord currentRecord = flowRecordService.getFlowRecord(request.getRecordId());

0 commit comments

Comments
 (0)