Skip to content

Deprecate jobRepository method in JobBuilderHelper & StepBuilderHelper #4326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
acktsap opened this issue Mar 15, 2023 · 1 comment
Closed

Comments

@acktsap
Copy link
Contributor

acktsap commented Mar 15, 2023

As of 5.0.0, it's recommanded to use JobBuilder, StepBuilder with JobRepository like this.

@Bean
public Job testJob(JobRepository jobRepository) {
    return new JobBuilder("testJob", jobRepository)
        .start(
            new StepBuilder("testStep", jobRepository)
                .tasklet((a, b) -> RepeatStatus.FINISHED, new ResourcelessTransactionManager())
                .build()
        )
        .build();
}

But i still can set JobRepository when building Job or Step like this.

@Bean
public Job testJob(JobRepository jobRepository) {
    return new JobBuilder("testJob", jobRepository)
        .start(
            new StepBuilder("testStep", jobRepository)
                .tasklet((a, b) -> RepeatStatus.FINISHED, new ResourcelessTransactionManager())
                .repository(jobRepository) // this
                .build()
        )
        .repository(jobRepository) // this
        .build();
}

It looks redundant since it's already set in constructor. So, how about remove repository method in JobBuilderHelper and StepBuilderHelper? Maybe it's better to deprecate first and remove in 6.0.0

/**
* Sets the job repository for the job.
* @param jobRepository the job repository (mandatory)
* @return this to enable fluent chaining
*/
public B repository(JobRepository jobRepository) {
properties.jobRepository = jobRepository;
@SuppressWarnings("unchecked")
B result = (B) this;
return result;
}

public B repository(JobRepository jobRepository) {
properties.jobRepository = jobRepository;
return self();
}

@acktsap acktsap added the status: waiting-for-triage Issues that we did not analyse yet label Mar 15, 2023
@acktsap acktsap changed the title Deprecate jobRepository method in Job [Deprecate jobRepository method in JobBuilderHelper & StepBuilderHelper Mar 15, 2023
@acktsap acktsap closed this as completed Mar 15, 2023
@acktsap acktsap changed the title [Deprecate jobRepository method in JobBuilderHelper & StepBuilderHelper Deprecate jobRepository method in JobBuilderHelper & StepBuilderHelper Mar 15, 2023
@acktsap acktsap reopened this Mar 15, 2023
@fmbenhassine
Copy link
Contributor

Thank you for reporting this. It makes sense, and indeed, it could be confusing. I will plan the deprecation for v5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants