Browse Source

fix some code smell problems

1. use Collections.isEmpt() instead of size() > 0
2. make if statements more readable
pull/3/MERGE
Zhou Zheng 4 years ago
parent
commit
6e5145f7c4
  1. 2
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
  2. 4
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java
  3. 2
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java

@ -635,7 +635,7 @@ public class ExecutorService extends BaseService{
*/
private boolean checkValidForcedSuccessTask(int processInstanceId) {
List<Integer> forcedSuccessList = processService.findTaskIdByInstanceState(processInstanceId, ExecutionStatus.FORCED_SUCCESS);
if (forcedSuccessList != null && forcedSuccessList.size() > 0) {
if (forcedSuccessList != null && !forcedSuccessList.isEmpty()) {
return true;
}

4
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterExecThread.java

@ -1186,8 +1186,7 @@ public class MasterExecThread implements Runnable {
// stop tasks which is retrying if forced success happens
if (task.taskCanRetry()) {
TaskInstance tmpTask = processService.findTaskInstanceById(task.getId());
if (tmpTask != null) {
if (tmpTask.getState().equals(ExecutionStatus.FORCED_SUCCESS)) {
if (tmpTask != null && tmpTask.getState().equals(ExecutionStatus.FORCED_SUCCESS)) {
task.setState(tmpTask.getState());
logger.info("task: {} has been forced success, put it into complete task list and stop retrying", task.getName());
removeTaskFromStandbyList(task);
@ -1196,7 +1195,6 @@ public class MasterExecThread implements Runnable {
continue;
}
}
}
DependResult dependResult = getDependResultForTask(task);
if (DependResult.SUCCESS == dependResult) {
if (retryTaskIntervalOverTime(task)) {

2
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

@ -790,7 +790,7 @@ public class ProcessService {
List<Integer> forcedSuccessList = this.findTaskIdInSubProcessByStatusAndType(taskInstanceId,
new ExecutionStatus[]{ExecutionStatus.FORCED_SUCCESS},
null);
if (forcedSuccessList != null && forcedSuccessList.size() > 0) {
if (forcedSuccessList != null && !forcedSuccessList.isEmpty()) {
return true;
}

Loading…
Cancel
Save