Closed
Description
Bug description
JdbcCursorItemReaderBuilder
defaults verifyCursorPosition
to false, despite its Javadoc claiming the opposite. This is also opposite the behavior you get if you build a JdbcCursorItemReader
directly. The javadoc currently reads
/**
* Indicates if the reader should verify the current position of the
* {@link java.sql.ResultSet} after being passed to the {@link RowMapper}. Defaults
* to true.
*
* @param verifyCursorPosition indicator
* @return this instance for method chaining
* @see JdbcCursorItemReader#setVerifyCursorPosition(boolean)
*/
Environment
Spring Batch 4.2.4. Appears to be the case in newer versions as well.
Expected behavior
I would expect JdbcCursorItemReaderBuilder
to build a reader with verifyCursorPosition = true
if not explicitly set, since this matches the default behavior of JdbcCursorItemReader
.
Or, at minimum, the javadoc on JdbcCursorItemReaderBuilder#verifyCursorPosition
should be updated.
Minimal Complete Reproducible example
public void testVerifyCursorPosition() {
JdbcCursorItemReader<Object> reader = new JdbcCursorItemReaderBuilder<>()
.name("name")
.sql("select 1")
.dataSource(new SimpleDriverDataSource())
.rowMapper((rs, i) -> null)
//.verifyCursorPosition(true) <-- the default according to the javadoc
.build();
assertTrue((boolean) ReflectionTestUtils.getField(reader, "verifyCursorPosition")); // fails
}