-
Notifications
You must be signed in to change notification settings - Fork 41.3k
Migrate to Spring Batch 6 #46216
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
base: main
Are you sure you want to change the base?
Migrate to Spring Batch 6 #46216
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. There are a number of things we need to fix before going forward. I've added comments.
@@ -172,6 +172,7 @@ protected ExecutionContextSerializer getExecutionContextSerializer() { | |||
: super.getExecutionContextSerializer(); | |||
} | |||
|
|||
@SuppressWarnings("removal") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what to make of this. The method is deprecated but the class isn't. If we don't want this to be configurable going forward, I'd rather remove the override (and the ObjectProvider
)
import org.springframework.core.convert.support.ConfigurableConversionService; | ||
|
||
/** | ||
* Callback interface that can be implemented by beans wishing to customize the | ||
* {@link ConfigurableConversionService} that is | ||
* {@link DefaultBatchConfiguration#getConversionService provided by | ||
* {@link JdbcDefaultBatchConfiguration#getConversionService provided by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should relax the javadoc a bit. It looks weird that we refer to that method. Something like
Callback interface that can be implemented by beans wishing to customize the ConfigurableConversionService that is use by the batch infrastructure while retaining its default auto-configuration.
private JobParameters getNextJobParameters(Job job, JobParameters jobParameters) { | ||
if (this.jobRepository != null && this.jobRepository.isJobInstanceExists(job.getName(), jobParameters)) { | ||
if (this.jobRepository != null && this.jobRepository.getJobInstance(job.getName(), jobParameters) != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something should be adapted in Spring Batch here. JobRepository
isn't deprecated but JobExplorer
is. The former extends the latter so any method that is not specified in the child is flagged as deprecated.
.getNextJobParameters(job) | ||
.toJobParameters(); | ||
return merge(nextParameters, jobParameters); | ||
} | ||
|
||
@SuppressWarnings("deprecated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I see what this suppresses.
@@ -114,6 +107,7 @@ | |||
* @author Yanming Zhou | |||
*/ | |||
@ExtendWith(OutputCaptureExtension.class) | |||
@SuppressWarnings("removal") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the plan to deal with those deprecations?
// the following assertion should pass as taskExecutor is inherited from | ||
// TaskExecutorJobLauncher | ||
// assertThat(context.getBean(JobOperator.class)).hasFieldOrPropertyWithValue("taskExecutor", | ||
// batchTaskExecutor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't comment code like that.
The assertion does not pass because context.getBean(JobOperator.class)
returns a JDK Proxy. And that proxy does not have such field. We should figure out why it returns a proxy and it didn't before.
@@ -226,6 +227,7 @@ SimpleJobBuilder configureJob() { | |||
} | |||
|
|||
@EnableBatchProcessing | |||
@EnableJdbcJobRepository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you consider adding an attribute to @EnableBatchProcessing
Looking at the code sample there, it looks odd to me and the second annotation does not make it very obvious it's Spring Batch specific.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I understand it's a bit similar to Spring Session, we can ignore this. I also missed "Job" from the annotation name.
This PR upgrades Spring Boot 4 to Spring Batch 6.
Most of the changes are documented here: https://github.com/spring-projects/spring-batch/wiki/Spring-Batch-6.0-Migration-Guide