Hansjoerg's update and sample project copied from email:
I had time this morning to have a look at the problem and to write a small test in order to reproduce it. Please have a look at the attached Eclipse/STS project. In order to reproduce the problem, just point the output resource to a disk/memory stick with less than 5MB of free space. I actually wanted to put it directly in the JIRA, however, it seems I don’t have the privileges to add attachments.
The project also includes a patched version of TransactionAwareBufferedWriter where I initiated the flush of the writer in the afterCommit method. This works in the way, that the job is indeed terminated with status FAILED. However, according to the JavaDoc of afterCommit, it is called after the transaction was successfully commited. Which means, that the position counters/pointers of the reader and writer are already updated and therefore persisted in the executionContext of the job/step. Hence, a restart would fail, respectively would be inconsistent, since the pointers are already positioned after the failing chunk and not at their beginning.
I also tried to make the flush in the beforeCommit method. However, the result in this case was an Unknown-exitstate with the message, that a Restart is not possible.
If you have further questions, don’t hesitate to contact me.