Bug description
After upgrading from Spring Batch 5.x to 6.x, ChunkListener callbacks are no longer invoked when defined on an ItemReader.
This affects both of the following approaches:
• Implementing ChunkListener directly on the ItemReader
• Using the @BeforeChunk annotation
Both approaches worked as expected in Spring Batch 5.x, but in Spring Batch 6.x neither beforeChunk nor methods annotated with @BeforeChunk are called.
The step itself executes normally and read() is invoked, but chunk lifecycle callbacks are silently skipped.
I could not find any mention of this behavioral change in the migration guide or reference documentation.
Environment
• Spring Batch version: 6.x
• Spring Boot version: 4.0.1
• Java version: 21
• Language: Kotlin
Steps to reproduce
- Create an ItemReader bean annotated with @StepScope
- Define chunk lifecycle logic using either:
• ChunkListener#beforeChunk
• a method annotated with @BeforeChunk
- Register the reader normally in a chunk-oriented step
- Run the job
Example Using ChunkListener
@Component
@StepScope
class TestReader() : ItemReader<Long>, ChunkListener<Long, Long> {
private val logger = LoggerFactory.getLogger(this::class.simpleName)
override fun beforeChunk(chunk: Chunk<Long>) {
logger.info("before chunk") // never invoked in Spring Batch 6.x
}
override fun read(): Long? {
return 10000L
}
}
Expected behavior
Chunk lifecycle callbacks (beforeChunk, @BeforeChunk) should be invoked before each chunk, as they were in Spring Batch 5.x.
Bug description
After upgrading from Spring Batch 5.x to 6.x, ChunkListener callbacks are no longer invoked when defined on an ItemReader.
This affects both of the following approaches:
• Implementing ChunkListener directly on the ItemReader
• Using the @BeforeChunk annotation
Both approaches worked as expected in Spring Batch 5.x, but in Spring Batch 6.x neither beforeChunk nor methods annotated with @BeforeChunk are called.
The step itself executes normally and read() is invoked, but chunk lifecycle callbacks are silently skipped.
I could not find any mention of this behavioral change in the migration guide or reference documentation.
Environment
• Spring Batch version: 6.x
• Spring Boot version: 4.0.1
• Java version: 21
• Language: Kotlin
Steps to reproduce
• ChunkListener#beforeChunk
• a method annotated with @BeforeChunk
Example Using ChunkListener
Expected behavior
Chunk lifecycle callbacks (beforeChunk, @BeforeChunk) should be invoked before each chunk, as they were in Spring Batch 5.x.