Incorrect Chunk property value in implementation of ItemWriter write method #4560
Labels
for: backport-to-5.0.x
Issues that will be back-ported to the 5.0.x line
for: backport-to-5.1.x
Issues that will be back-ported to the 5.1.x line
in: core
type: bug
Milestone
Uh oh!
There was an error while loading. Please reload this page.
Bug description
I was implementing an ItemWriter class by overriding write method. I wanted to add a condition to do if the chunk is the last one. I saw that there is a
isEnd()
method in itself. But it never comes true even if the chunk is the last chunk.I debugged the spring batch classes.
end
property of the actual chunk object is true when it is the last chunk. However, the chunk object are reproduced by the actual chunk. The reproduced chunk passing to ItemWrite write method. It does not preserve variables such asend
.I also opened a pull request for this problem to fix. A test case is included in PR.
Environment
Java Version: 21 (openjdk-21.0.2)
Spring Batch Core: 5.0.0 (also tried 5.2.0)
Spring Batch Infrastructure: 5.1.0
Steps to reproduce
chunk.isEnd()
in the write method of the implementation.Expected behavior
In the last call of write method,
chunk.isEnd()
should be true.Minimal Complete Reproducible example
The text was updated successfully, but these errors were encountered: