BATCH-610:JdbcCursorItemReader can now be closed and opened again without issue.
This commit is contained in:
@@ -230,6 +230,7 @@ public class JdbcCursorItemReader extends ExecutionContextUserSupport implements
|
||||
JdbcUtils.closeStatement(this.preparedStatement);
|
||||
JdbcUtils.closeConnection(this.con);
|
||||
bufferredReader = null;
|
||||
rs = null;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -343,7 +344,7 @@ public class JdbcCursorItemReader extends ExecutionContextUserSupport implements
|
||||
*/
|
||||
public void open(ExecutionContext context) {
|
||||
Assert.state(!initialized, "Stream is already initialized. Close before re-opening.");
|
||||
Assert.isNull(rs);
|
||||
Assert.isNull(rs, "ResultSet still open! Close before re-opening.");
|
||||
Assert.notNull(context, "ExecutionContext must not be null");
|
||||
executeQuery();
|
||||
initialized = true;
|
||||
|
||||
@@ -55,5 +55,25 @@ public abstract class CommonItemStreamItemReaderTests extends CommonItemReaderTe
|
||||
Foo fooAfterRestart = (Foo) tested.read();
|
||||
assertEquals(3, fooAfterRestart.getValue());
|
||||
}
|
||||
|
||||
public void testReopen() throws Exception {
|
||||
testedAsStream().update(executionContext);
|
||||
|
||||
Foo foo1 = (Foo) tested.read();
|
||||
assertEquals(1, foo1.getValue());
|
||||
|
||||
Foo foo2 = (Foo) tested.read();
|
||||
assertEquals(2, foo2.getValue());
|
||||
|
||||
testedAsStream().update(executionContext);
|
||||
|
||||
// create new input source
|
||||
testedAsStream().close(executionContext);
|
||||
|
||||
testedAsStream().open(executionContext);
|
||||
|
||||
Foo fooAfterRestart = (Foo) tested.read();
|
||||
assertEquals(3, fooAfterRestart.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user