Fixed SqlCursorInputSource to correctly handled blank restart data.

This commit is contained in:
lucasward
2007-09-05 19:53:43 +00:00
parent 570a86ee6d
commit 79c4672e6c
2 changed files with 13 additions and 1 deletions

View File

@@ -414,9 +414,14 @@ public class SqlCursorInputSource implements InputSource, DisposableBean,
if (rs == null) {
executeQuery();
}
Properties restartProperties = data.getProperties();
if(restartProperties.containsKey(CURRENT_PROCESSED_ROW) == false){
return;
}
try {
this.currentProcessedRow = Integer.parseInt(data.getProperties()
this.currentProcessedRow = Integer.parseInt(restartProperties
.getProperty(CURRENT_PROCESSED_ROW));
rs.absolute(currentProcessedRow);
} catch (SQLException se) {

View File

@@ -7,6 +7,7 @@ import java.util.Properties;
import org.springframework.batch.repeat.context.RepeatContextSupport;
import org.springframework.batch.repeat.synch.BatchTransactionSynchronizationManager;
import org.springframework.batch.repeat.synch.RepeatSynchronizationManager;
import org.springframework.batch.restart.GenericRestartData;
import org.springframework.batch.restart.RestartData;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
@@ -94,6 +95,12 @@ public class SqlCursorInputSourceIntegrationTests extends AbstractTransactionalD
validateFoo(3, "bar3", 3, foo);
}
public void testRestartWithEmptyRestartData(){
RestartData restartData = new GenericRestartData(new Properties());
sqlCursorInputSource.restoreFrom(restartData);
}
public void testReadWithNullMapper(){
//calling read without a mapper should throw an exception.