spring-batch
spring-batch copied to clipboard
beforeStep/afterStep runs twice with step scoped beans using annotations and implementing StepExecutionListener at the same time [BATCH-2107]
Krishna Bhamidipati opened BATCH-2107 and commented
Spring Batch 2.1.8 introduced the @BeforeStep and @AfterStep annotations, in lieu of implementing StepExecutionListener.
If a class:
- both implements StepExecutionListener and uses the
@BeforeStep/@AfterStepannotations - is defined in step scope then the beforeStep/afterStep run twice.
However, if the class is not step scope, then the the beforeStep/afterStep run only once, as expected.
The attached project has a JUnit test (ExampleJobConfigurationTests) that demonstrates the above behavior. writer1 is step scope and writer2 is not. The console output reveals writer1's beforeStep and afterStep run twice whereas writer2's run only once.
Affects: 2.1.8, 2.1.9, 2.2.0, 2.2.1, 2.2.2
Attachments:
- sb-listener-test.zip (33.92 kB)
1 votes, 2 watchers
Thank you for opening the issue. Can you retry with the latest release of Spring Batch(5.0.2) and report back the results?
If the issue is reproducible, can you provide a sample project that uses the latest release of Spring Batch and that exhibits the behavior? To help you in reporting your issue, we have prepared a project template that you can use as a starting point. Please check the Issue Reporting Guidelines for more details about this.