spring-projects / spring-projects/spring-batch

SimpleJobLauncher not using jobIncrementer

Open
#4,397 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-reporter type: bug
Dominant language
Java
Stars
3k
Forks
2.5k
Avg merge
6d 53m
Merged PRs (30d)
3

Description

Please do a quick search on Github issues first, there might be already a duplicate issue for the one you are about to create.
If the bug is trivial, just go ahead and create the issue. Otherwise, please take a few moments and fill in the following sections:

Bug description
A clear and concise description of what the bug is about.

Simple Job Launcher not using JobParametersIncrementer

i want same result using that cli run but the test util is using the simple job launcher

so, i want to change the simpleJobLauncher

image

Environment
Please provide as many details as possible: Spring Batch version, Java version, which database you use if any, etc
spring batch 4.3
java 11

Steps to reproduce
Steps to reproduce the issue.

Expected behavior
A clear and concise description of what you expected to happen.

        jobLauncherTestUtils.setJob(job);
        var result = jobLauncherTestUtils.launchJob();
        Assertions.assertThat(result.getJobParameters().getString("year")).isEqualTo(DateTimeFormatter.ofPattern("yyyyMM").format(LocalDateTime.now()));
        Assertions.assertThat(result.getStatus()).isEqualTo(BatchStatus.COMPLETED);

Minimal Complete Reproducible example
Please provide a failing test or a minimal complete verifiable example that reproduces the issue.
Bug reports that are reproducible will take priority in resolution over reports that are not reproducible.

        jobLauncherTestUtils.setJob(job);
        var result = jobLauncherTestUtils.launchJob(job.getJobParametersIncrementer().getNext(jobLauncherTestUtils.getUniqueJobParameters()));
        Assertions.assertThat(result.getJobParameters().getString("year")).isEqualTo(DateTimeFormatter.ofPattern("yyyyMM").format(LocalDateTime.now()));
        Assertions.assertThat(result.getStatus()).isEqualTo(BatchStatus.COMPLETED);

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.

Research direction

Start by reading SimpleJobLauncher and JobLauncherTestUtils, then reproduce the behavior with the launchJob() snippets in the issue and compare it with the CLI result described there. Done means the test utility produces the expected incremented year parameter and the job completes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.