Browse Source

Fix timing scheduling trigger master service report to get command parameter null pointer exception (#12419)

3.2.0-release
Kerwin 2 years ago committed by GitHub
parent
commit
a8e23008ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      dolphinscheduler-scheduler-plugin/dolphinscheduler-scheduler-quartz/src/main/java/org/apache/dolphinscheduler/scheduler/quartz/ProcessScheduleTask.java
  2. 23
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessServiceImpl.java

2
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; package org.apache.dolphinscheduler.scheduler.quartz;
import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.ReleaseState; import org.apache.dolphinscheduler.common.enums.ReleaseState;
@ -36,7 +37,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean; import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.util.StringUtils;
import io.micrometer.core.annotation.Counted; import io.micrometer.core.annotation.Counted;
import io.micrometer.core.annotation.Timed; import io.micrometer.core.annotation.Timed;

23
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.enums.Direct.IN;
import static org.apache.dolphinscheduler.plugin.task.api.utils.DataQualityConstants.TASK_INSTANCE_ID; 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.Constants;
import org.apache.dolphinscheduler.common.enums.AuthorizationType; import org.apache.dolphinscheduler.common.enums.AuthorizationType;
import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.CommandType;
@ -135,7 +136,6 @@ import org.apache.dolphinscheduler.service.model.TaskNode;
import org.apache.dolphinscheduler.service.task.TaskPluginManager; import org.apache.dolphinscheduler.service.task.TaskPluginManager;
import org.apache.dolphinscheduler.service.utils.DagHelper; import org.apache.dolphinscheduler.service.utils.DagHelper;
import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.dolphinscheduler.spi.enums.ResourceType;
import org.apache.dolphinscheduler.spi.utils.StringUtils;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
@ -410,17 +410,18 @@ public class ProcessServiceImpl implements ProcessService {
@Counted("ds.workflow.create.command.count") @Counted("ds.workflow.create.command.count")
public int createCommand(Command command) { public int createCommand(Command command) {
int result = 0; int result = 0;
if (command != null) { if (command == null) {
// add command timezone return result;
Schedule schedule = scheduleMapper.queryByProcessDefinitionCode(command.getProcessDefinitionCode()); }
Map<String, String> commandParams = JSONUtils.toMap(command.getCommandParam()); // add command timezone
if (commandParams != null && schedule != null) { Schedule schedule = scheduleMapper.queryByProcessDefinitionCode(command.getProcessDefinitionCode());
commandParams.put(Constants.SCHEDULE_TIMEZONE, schedule.getTimezoneId()); if (schedule != null) {
command.setCommandParam(JSONUtils.toJsonString(commandParams)); Map<String, String> commandParams = StringUtils.isNotBlank(command.getCommandParam()) ? JSONUtils.toMap(command.getCommandParam()) : new HashMap<>();
} commandParams.put(Constants.SCHEDULE_TIMEZONE, schedule.getTimezoneId());
command.setId(null); command.setCommandParam(JSONUtils.toJsonString(commandParams));
result = commandMapper.insert(command);
} }
command.setId(null);
result = commandMapper.insert(command);
return result; return result;
} }

Loading…
Cancel
Save