Skip to content

partitioned-batch-job raises NPE when used with mutiple Partiton handlers #793

@nicolasduminil

Description

@nicolasduminil

Hello,

I modified the partitioned-batch-job sample such that to add the following method:

  @Bean
  public PartitionHandler partitionHandler2(TaskLauncher taskLauncher, JobExplorer jobExplorer, TaskRepository taskRepository)
  {
    Resource resource = this.resourceLoader.getResource("maven://fr.simplex_software.tests:partitioned-job:1.0-SNAPSHOT");
    DeployerPartitionHandler partitionHandler = new DeployerPartitionHandler(taskLauncher, jobExplorer, resource, "workerStep");
    List<String> commandLineArgs = new ArrayList<>(3);
    commandLineArgs.add("--spring.profiles.active=worker");
    commandLineArgs.add("--spring.cloud.task.initialize-enabled=false");
    commandLineArgs.add("--spring.batch.initializer.enabled=false");
    partitionHandler.setCommandLineArgsProvider(new PassThroughCommandLineArgsProvider(commandLineArgs));
    partitionHandler.setEnvironmentVariablesProvider(new SimpleEnvironmentVariablesProvider(this.environment));
    partitionHandler.setMaxWorkers(2);
    partitionHandler.setApplicationName("PartitionedBatchJobTask");
    return partitionHandler;
  }

Running the job raises the following exception:

2021-08-06 13:12:47.071 DEBUG 13084 --- [           main] o.s.c.t.r.support.SimpleTaskRepository   : Creating: 
TaskExecution{executionId=149, parentExecutionId=null, exitCode=null, taskName='null', startTime=null, endTime=null, 
exitMessage='null', externalExecutionId='null', errorMessage='null', arguments=[]}
2021-08-06 13:12:47.074 ERROR 13084 --- [           main] o.s.batch.core.step.AbstractStep         : Encountered an error 
executing step step1 in job partitionedJob-494091066

java.lang.NullPointerException: null
     at 
    org.springframework.cloud.task.batch.partition.DeployerPartitionHandler.launchWorker(DeployerPartitionHandler.java:347) 
    ~[spring-cloud-task-batch-2.3.3.jar:2.3.3]
     at 
    org.springframework.cloud.task.batch.partition.DeployerPartitionHandler.launchWorkers(DeployerPartitionHandler.java:313) 
    ~ [spring-cloud-task-batch-2.3.3.jar:2.3.3]
    ...

Please advise.

Many thanks in advance.

Just to mention that the NPE is raised at the line #347 of the DeployerPartitionHanlder class cause the taskExecution lcal property is null. This only happens as soon as there are 2 or more partition handlers in the job. Using different flows doesn't change anything.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions