在DeployerPartitonHandler类中获取TaskExecution参考的Null指针异常

时间:2019-04-11 10:42:56

标签: spring-cloud-task

我正在尝试在春季云任务项目中使用DeployerPartitonHandler为每个分区创建KubernetesTaskLauncher,以在Kubernetes环境中运行的SCDF中将批处理作业作为任务执行。

批处理作业首先根据条件创建任何分区,然后执行分区步骤以从表中读取数据并写入文件。

要使用XML Job配置实现DeployerPartitonHandler,我添加了具有针对分区处理程序和DeployerStepExecutionHandler的bean定义的Job配置类,并添加了要映射的Job XML所需的更改 DeployerPartitonHandler而不是基础TaskExecutorPartitionHandler步进。

但是当通过这些更改将任务作为任务执行时,我得到了

  

DeployerPartitonHandler类中TaskExecution参考的空指针异常。

出现错误,

java.lang.NullPointerException: null
    at org.springframework.cloud.task.batch.partition.DeployerPartitionHandler.launchWorker(DeployerPartitionHandler.java:289) ~[spring-cloud-task-batch-2.1.0.M2.jar:2.1.0.M2]
    at org.springframework.cloud.task.batch.partition.DeployerPartitionHandler.launchWorkers(DeployerPartitionHandler.java:265) ~[spring-cloud-task-batch-2.1.0.M2.jar:2.1.0.M2]

下面是第289行的DeployerPartitonHandler的代码及其抛出错误,因为TaskExecution对象为Null。

arguments.add(formatArgument(SPRING_CLOUD_TASK_NAME, String.format("%s_%s_%s",taskExecution.getTaskName(),

注意:在下面提到的beforeTask方法(在DeployerPartitonHandler类中定义)中,TaskExecution参考值设置正确,但是当调用在第289行时,此时TaskExecution为Null。

    @BeforeTask
    public void beforeTask(TaskExecution taskExecution) {
        this.taskExecution = taskExecution;

        if(this.commandLineArgsProvider == null) {
            SimpleCommandLineArgsProvider provider = new
                    SimpleCommandLineArgsProvider(taskExecution);
            this.commandLineArgsProvider = provider;

        }
    }

0 个答案:

没有答案
相关问题