diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/builder/JdbcCursorItemReaderBuilder.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/builder/JdbcCursorItemReaderBuilder.java index 463da9165..1a7e62dda 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/builder/JdbcCursorItemReaderBuilder.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/builder/JdbcCursorItemReaderBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,6 +36,7 @@ import org.springframework.util.StringUtils; * @author Drummond Dawson * @author Mahmoud Ben Hassine * @author Ankur Trapasiya + * @author Parikshit Dutta * @since 4.0 */ public class JdbcCursorItemReaderBuilder { @@ -50,7 +51,7 @@ public class JdbcCursorItemReaderBuilder { private boolean ignoreWarnings; - private boolean verifyCursorPosition; + private boolean verifyCursorPosition = true; private boolean driverSupportsAbsolute; diff --git a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JdbcCursorItemReaderBuilderTests.java b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JdbcCursorItemReaderBuilderTests.java index 521ee3849..accedc444 100644 --- a/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JdbcCursorItemReaderBuilderTests.java +++ b/spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/builder/JdbcCursorItemReaderBuilderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2020 the original author or authors. + * Copyright 2016-2021 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,6 +48,7 @@ import static org.junit.Assert.fail; * @author Michael Minella * @author Drummond Dawson * @author Ankur Trapasiya + * @author Parikshit Dutta */ public class JdbcCursorItemReaderBuilderTests { @@ -314,6 +315,17 @@ public class JdbcCursorItemReaderBuilderTests { assertTrue((boolean) ReflectionTestUtils.getField(reader, "connectionAutoCommit")); } + @Test + public void testVerifyCursorPositionDefaultToTrue() { + JdbcCursorItemReader reader = new JdbcCursorItemReaderBuilder() + .dataSource(this.dataSource) + .name("fooReader") + .sql("SELECT * FROM FOO ORDER BY FIRST") + .beanRowMapper(Foo.class) + .build(); + assertTrue((boolean) ReflectionTestUtils.getField(reader, "verifyCursorPosition")); + } + @Test public void testValidation() { try {