From 7ecd38f7d6ff25e05cb29634296415745e33dd25 Mon Sep 17 00:00:00 2001 From: Yelli <51317527+Yeleights@users.noreply.github.com> Date: Sat, 4 Jan 2020 11:32:07 +0800 Subject: [PATCH] fix sonar bug: change condition & not enough arguments (#1692) * 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 --- .../api/service/ProcessInstanceService.java | 7 ++++--- .../common/utils/HadoopUtils.java | 3 +-- .../server/worker/task/sql/SqlTask.java | 15 ++++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java index 5eae886680..d27dfc85d5 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java @@ -489,13 +489,14 @@ public class ProcessInstanceService extends BaseDAGService { } ProcessInstance processInstance = processDao.findProcessInstanceDetailById(processInstanceId); List taskInstanceList = processDao.findValidTaskListByProcessId(processInstanceId); - //process instance priority - int processInstancePriority = processInstance.getProcessInstancePriority().ordinal(); - if (processInstance == null) { + + if (null == processInstance) { putMsg(result, Status.PROCESS_INSTANCE_NOT_EXIST, processInstanceId); return result; } + //process instance priority + int processInstancePriority = processInstance.getProcessInstancePriority().ordinal(); // delete zk queue if (CollectionUtils.isNotEmpty(taskInstanceList)){ for (TaskInstance taskInstance : taskInstanceList){ diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java index ef933edfbb..afc3c44825 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/HadoopUtils.java @@ -118,7 +118,7 @@ public class HadoopUtils implements Closeable { configuration.set(Constants.FS_DEFAULTFS,defaultFSProp); fsRelatedProps.forEach((key, value) -> configuration.set(key, value)); }else{ - logger.error("property:{} can not to be empty, please set!"); + logger.error("property:{} can not to be empty, please set!", Constants.FS_DEFAULTFS ); throw new RuntimeException("property:{} can not to be empty, please set!"); } }else{ @@ -337,7 +337,6 @@ public class HadoopUtils implements Closeable { * @throws Exception errors */ public FileStatus[] listFileStatus(String filePath)throws Exception{ - Path path = new Path(filePath); try { return fs.listStatus(new Path(filePath)); } catch (IOException e) { diff --git a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java index d88d39cb91..bacb3f22eb 100644 --- a/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java +++ b/dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/worker/task/sql/SqlTask.java @@ -119,6 +119,13 @@ public class SqlTask extends AbstractTask { } dataSource= processDao.findDataSourceById(sqlParameters.getDatasource()); + + if (null == dataSource){ + logger.error("datasource not exists"); + exitStatusCode = -1; + return; + } + logger.info("datasource name : {} , type : {} , desc : {} , user_id : {} , parameter : {}", dataSource.getName(), dataSource.getType(), @@ -126,12 +133,6 @@ public class SqlTask extends AbstractTask { dataSource.getUserId(), dataSource.getConnectionParams()); - if (dataSource == null){ - logger.error("datasource not exists"); - exitStatusCode = -1; - return; - } - Connection con = null; List createFuncs = null; try { @@ -177,7 +178,7 @@ public class SqlTask extends AbstractTask { try { con.close(); } catch (SQLException e) { - throw e; + logger.error(e.getMessage(),e); } } }