spring-projects / spring-batch

Spring Batch is a framework for writing batch applications using Java and Spring
http://projects.spring.io/spring-batch/
Apache License 2.0
2.73k stars 2.35k forks source link

beforeStep/afterStep runs twice with step scoped beans using annotations and implementing StepExecutionListener at the same time [BATCH-2107] #1490

Open spring-projects-issues opened 11 years ago

spring-projects-issues commented 11 years ago

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:

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:

1 votes, 2 watchers

cppwfs commented 1 year ago

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.