You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ke...@apache.org on 2022/10/19 02:50:12 UTC
[dolphinscheduler] 01/02: Fix timing scheduling trigger master service report to get command parameter null pointer exception (#12419)
This is an automated email from the ASF dual-hosted git repository.
kerwin pushed a commit to branch 3.1.1-prepare
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
commit c79115c8d81b8f551f9b8777ea4416e82011853b
Author: Kerwin <37...@users.noreply.github.com>
AuthorDate: Wed Oct 19 09:43:36 2022 +0800
Fix timing scheduling trigger master service report to get command parameter null pointer exception (#12419)
---
.../scheduler/quartz/ProcessScheduleTask.java | 2 +-
.../service/process/ProcessServiceImpl.java | 23 +++++++++++-----------
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/ProcessScheduleTask.java b/dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/ProcessScheduleTask.java
index 2b546940ec..dccbd1e4cf 100644
--- a/dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/ProcessScheduleTask.java
+++ b/dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/ProcessScheduleTask.java
@@ -17,6 +17,7 @@
package org.apache.dolphinscheduler.scheduler.quartz;
+import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
@@ -36,7 +37,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
-import org.springframework.util.StringUtils;
import io.micrometer.core.annotation.Counted;
import io.micrometer.core.annotation.Timed;
diff --git a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
index 0aad520c41..ebba2d8781 100644
--- a/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
+++ b/dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java
@@ -32,6 +32,7 @@ import static org.apache.dolphinscheduler.plugin.task.api.enums.DataType.VARCHAR
import static org.apache.dolphinscheduler.plugin.task.api.enums.Direct.IN;
import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TASK_INSTANCE_ID;
+import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.CommandType;
@@ -136,7 +137,6 @@ import org.apache.dolphinscheduler.service.expand.CuringParamsService;
import org.apache.dolphinscheduler.service.log.LogClientService;
import org.apache.dolphinscheduler.service.task.TaskPluginManager;
import org.apache.dolphinscheduler.spi.enums.ResourceType;
-import org.apache.dolphinscheduler.spi.utils.StringUtils;
import org.apache.commons.collections.CollectionUtils;
@@ -401,17 +401,18 @@ public class ProcessServiceImpl implements ProcessService {
@Counted("ds.workflow.create.command.count")
public int createCommand(Command command) {
int result = 0;
- if (command != null) {
- // add command timezone
- Schedule schedule = scheduleMapper.queryByProcessDefinitionCode(command.getProcessDefinitionCode());
- Map<String, String> commandParams = JSONUtils.toMap(command.getCommandParam());
- if (commandParams != null && schedule != null) {
- commandParams.put(Constants.SCHEDULE_TIMEZONE, schedule.getTimezoneId());
- command.setCommandParam(JSONUtils.toJsonString(commandParams));
- }
- command.setId(null);
- result = commandMapper.insert(command);
+ if (command == null) {
+ return result;
+ }
+ // add command timezone
+ Schedule schedule = scheduleMapper.queryByProcessDefinitionCode(command.getProcessDefinitionCode());
+ if (schedule != null) {
+ Map<String, String> commandParams = StringUtils.isNotBlank(command.getCommandParam()) ? JSONUtils.toMap(command.getCommandParam()) : new HashMap<>();
+ commandParams.put(Constants.SCHEDULE_TIMEZONE, schedule.getTimezoneId());
+ command.setCommandParam(JSONUtils.toJsonString(commandParams));
}
+ command.setId(null);
+ result = commandMapper.insert(command);
return result;
}