Browse Source

fix bug sonar: add null check in daghelper (#1719)

* modify FileUtils.readFile2Str

* #1300 Add right alignment function in sql email content

* cancel formatted for alert_mail_template.ftl

* #747 sql task password Log desensitization

* cancel mail_temple

* edit ExcelUtils

* modify test method name

* #747 sql task password Log desensitization

* #1544 workflow import

* Constants add DATASOURCE_PASSWORD_REGEX

* #747 sql task password Log desensitization

* deal with import project have sub process

* modify export process addTaskNodeParam method name

* add testAddTaskNodeSpecialParam UT

* add ProcessDefinitionServiceTest-ut to pom

* add testImportSubProcess in ProcessDefinitionServiceTest

* add testImportSubProcess in ProcessDefinitionServiceTest

* add testImportProcessDefinition

* fix sonar bug: not enough arguments

* fix sonar bug: change condition & not enough arguments

* fix bug sonar: add null check in daghelper && add hashcode method in ProcessData

* fix bug sonar: add null check in daghelper

* CollectionUtils.isEmpty()
pull/2/head
Yelli 5 years ago committed by qiaozhanwei
parent
commit
13d5a5ae9b
  1. 31
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java

31
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/utils/DagHelper.java

@ -78,17 +78,17 @@ public class DagHelper {
List<String> startNodeList = startNodeNameList; List<String> startNodeList = startNodeNameList;
if(taskDependType != TaskDependType.TASK_POST if(taskDependType != TaskDependType.TASK_POST
&& startNodeList.size() == 0){ && CollectionUtils.isEmpty(startNodeList)){
logger.error("start node list is empty! cannot continue run the process "); logger.error("start node list is empty! cannot continue run the process ");
return destFlowNodeList; return destFlowNodeList;
} }
List<TaskNode> destTaskNodeList = new ArrayList<>(); List<TaskNode> destTaskNodeList = new ArrayList<>();
List<TaskNode> tmpTaskNodeList = new ArrayList<>(); List<TaskNode> tmpTaskNodeList = new ArrayList<>();
if (taskDependType == TaskDependType.TASK_POST if (taskDependType == TaskDependType.TASK_POST
&& recoveryNodeNameList.size() > 0) { && CollectionUtils.isNotEmpty(recoveryNodeNameList)) {
startNodeList = recoveryNodeNameList; startNodeList = recoveryNodeNameList;
} }
if (startNodeList == null || startNodeList.size() == 0) { if (CollectionUtils.isEmpty(startNodeList)) {
// no special designation start nodes // no special designation start nodes
tmpTaskNodeList = taskNodeList; tmpTaskNodeList = taskNodeList;
} else { } else {
@ -126,10 +126,8 @@ public class DagHelper {
List<TaskNode> resultList = new ArrayList<>(); List<TaskNode> resultList = new ArrayList<>();
for (TaskNode taskNode : taskNodeList) { for (TaskNode taskNode : taskNodeList) {
List<String> depList = taskNode.getDepList(); List<String> depList = taskNode.getDepList();
if (depList != null) { if (null != depList && null != startNode && depList.contains(startNode.getName())) {
if (depList.contains(startNode.getName())) { resultList.addAll(getFlowNodeListPost(taskNode, taskNodeList));
resultList.addAll(getFlowNodeListPost(taskNode, taskNodeList));
}
} }
} }
@ -149,9 +147,12 @@ public class DagHelper {
List<TaskNode> resultList = new ArrayList<>(); List<TaskNode> resultList = new ArrayList<>();
List<String> depList = startNode.getDepList(); List<String> depList = new ArrayList<>();
resultList.add(startNode); if (null != startNode) {
if (depList == null || depList.size() == 0) { depList = startNode.getDepList();
resultList.add(startNode);
}
if (CollectionUtils.isEmpty(depList)) {
return resultList; return resultList;
} }
for (String depNodeName : depList) { for (String depNodeName : depList) {
@ -180,7 +181,10 @@ public class DagHelper {
TaskDependType depNodeType) throws Exception { TaskDependType depNodeType) throws Exception {
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class);
List<TaskNode> taskNodeList = processData.getTasks(); List<TaskNode> taskNodeList = new ArrayList<>();
if (null != processData) {
taskNodeList = processData.getTasks();
}
List<TaskNode> destTaskNodeList = generateFlowNodeListByStartNode(taskNodeList, startNodeNameList, recoveryNodeNameList, depNodeType); List<TaskNode> destTaskNodeList = generateFlowNodeListByStartNode(taskNodeList, startNodeNameList, recoveryNodeNameList, depNodeType);
if (destTaskNodeList.isEmpty()) { if (destTaskNodeList.isEmpty()) {
return null; return null;
@ -201,7 +205,10 @@ public class DagHelper {
Map<String, TaskNode> forbidTaskNodeMap = new ConcurrentHashMap<>(); Map<String, TaskNode> forbidTaskNodeMap = new ConcurrentHashMap<>();
ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class); ProcessData processData = JSONUtils.parseObject(processDefinitionJson, ProcessData.class);
List<TaskNode> taskNodeList = processData.getTasks(); List<TaskNode> taskNodeList = new ArrayList<>();
if (null != processData) {
taskNodeList = processData.getTasks();
}
for(TaskNode node : taskNodeList){ for(TaskNode node : taskNodeList){
if(node.isForbidden()){ if(node.isForbidden()){
forbidTaskNodeMap.putIfAbsent(node.getName(), node); forbidTaskNodeMap.putIfAbsent(node.getName(), node);

Loading…
Cancel
Save