Fixed SqlCursorInputSource to correctly handled blank restart data.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user