Hi snicoll,
Thanks for this info. However, I just found out that my current troubles are caused by something else other than failing to set saveState on JdbcCursorItemReader to false.
As previously mentioned, my problem actually happens when I try to return items from an ArrayList on ItemReader.read() when that list is not empty (I call superclass JdbcCursorItemReader's read() method otherwise). The list represents skipped items from a previous failed execution of the same step. Thus in this instance, this is actually not related to resetting the cursor position.
My ItemReader's "pre-reading" was actually caused by a property in the step execution context ("org.springframework.batch.core.step.item.ChunkMon itor.OFFSET") which got set to the number of items successfully read and written in the previous failed execution.
As logically I do not need this OFFSET since I am now working from a list of the skipped items (as opposed to working on the same population of items retrieved from the database in the previous execution), I just resolved the issue by setting ChunkMonitor.OFFSET to 0 in the open() method of my JdbcCursorItemReader subclass as show in snippet below:
Code:
@Override
publicvoid open(ExecutionContext executionContext) throws ItemStreamException
{
try {
if(executionContext.containsKey("org.springframework.batch.core.step.item.ChunkMonitor.OFFSET")){
log.debug("executionContext ChunkMonitor.OFFSET: " +
executionContext.getInt("org.springframework.batch.core.step.item.ChunkMonitor.OFFSET"));
log.debug("setting ChunkMonitor.OFFSET to 0...");
executionContext.putInt("org.springframework.batch.core.step.item.ChunkMonitor.OFFSET", 0);
}
...
Now I don't have items that are being read before my ItemWriter's open() method is called and so I no longer miss any item.
Thanks for the help,
Johannis