Skip to content

Commit 40db8a7

Browse files
committed
Polish
1 parent 1c9c30c commit 40db8a7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

spring-batch-infrastructure/src/main/java/org/springframework/batch/item/database/AbstractCursorItemReader.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public abstract class AbstractCursorItemReader<T> extends AbstractItemCountingIt
135135

136136
private boolean useSharedExtendedConnection = false;
137137

138-
private boolean connectionAutoCommit;
138+
private Boolean connectionAutoCommit;
139139

140140
private boolean initialConnectionAutoCommit;
141141

@@ -396,7 +396,9 @@ protected void doClose() throws Exception {
396396
rs = null;
397397
cleanupOnClose();
398398

399-
this.con.setAutoCommit(initialConnectionAutoCommit);
399+
if(this.con != null) {
400+
this.con.setAutoCommit(this.initialConnectionAutoCommit);
401+
}
400402

401403
if (useSharedExtendedConnection && dataSource instanceof ExtendedConnectionDataSourceProxy) {
402404
((ExtendedConnectionDataSourceProxy)dataSource).stopCloseSuppression(this.con);
@@ -445,7 +447,7 @@ protected void initializeConnection() {
445447

446448
this.initialConnectionAutoCommit = this.con.getAutoCommit();
447449

448-
if (this.con.getAutoCommit() != this.connectionAutoCommit) {
450+
if (this.connectionAutoCommit != null && this.con.getAutoCommit() != this.connectionAutoCommit) {
449451
this.con.setAutoCommit(this.connectionAutoCommit);
450452
}
451453
}

spring-batch-infrastructure/src/test/java/org/springframework/batch/item/database/JdbcCursorItemReaderCommonTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class JdbcCursorItemReaderCommonTests extends AbstractDatabaseItemStreamI
2929
@Override
3030
protected ItemReader<Foo> getItemReader() throws Exception {
3131

32-
JdbcCursorItemReader<Foo> result = new JdbcCursorItemReader<Foo>();
32+
JdbcCursorItemReader<Foo> result = new JdbcCursorItemReader<>();
3333
result.setDataSource(getDataSource());
3434
result.setSql("select ID, NAME, VALUE from T_FOOS");
3535
result.setIgnoreWarnings(true);

0 commit comments

Comments
 (0)