Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open
#793 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
java, spring

Research direction

Start with the partitioned-batch-job sample and inspect DeployerPartitionHandler.launchWorker at line 347, where taskExecution is reported as null when multiple partition handlers are configured. Run the sample with two or more handlers and compare the execution path with a single handler. Done means the multi-handler job completes without the NullPointerException and the behavior is covered by a regression check.

Written by the indexing model from the issue text.

Description

for: team-attention

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.

Dominant language
Java
Stars
446
Forks
310
Avg merge
18h 18m
Merged PRs (30d)
6

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from spring-cloud/spring-cloud-task

All issues in spring-cloud/spring-cloud-task

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.