BATCH-1359: Throw helpful error from JdbcCursorItemReader if read() called before open()

This commit is contained in:
dhgarrette
2009-08-06 04:22:16 +00:00
parent 638a379ba0
commit 9d694b7d6c
2 changed files with 15 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ReaderNotOpenException;
import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.dao.InvalidDataAccessApiUsageException;
@@ -469,6 +470,10 @@ public class JdbcCursorItemReader<T> extends AbstractItemCountingItemStreamItemR
*/
@SuppressWarnings("unchecked")
protected T doRead() throws Exception {
if (rs == null) {
throw new ReaderNotOpenException("Reader must be open before it can be read.");
}
try {
if (!rs.next()) {
return null;