BATCH-413: DrivingQueryItemReader now throws an exception if no keys are returned from the KeyGenerator.

This commit is contained in:
lucasward
2008-03-04 19:14:38 +00:00
parent bf607c315e
commit 77b6a7c34c
2 changed files with 27 additions and 2 deletions

View File

@@ -22,6 +22,7 @@ import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStream;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.DataRetrievalFailureException;
import org.springframework.util.Assert;
/**
@@ -139,6 +140,9 @@ public class DrivingQueryItemReader implements ItemReader, InitializingBean,
Assert.state(keys == null && !initialized, "Cannot open an already opened input source"
+ ", call close() first.");
keys = keyGenerator.retrieveKeys(executionContext);
if(keys == null || keys.size() == 0){
throw new DataRetrievalFailureException("KeyGenerator must return at least 1 key");
}
keysIterator = keys.listIterator();
initialized = true;
}