Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
mminella committed Nov 30, 2017
1 parent 1c9c30c commit 40db8a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public abstract class AbstractCursorItemReader<T> extends AbstractItemCountingIt

private boolean useSharedExtendedConnection = false;

private boolean connectionAutoCommit;
private Boolean connectionAutoCommit;

private boolean initialConnectionAutoCommit;

Expand Down Expand Up @@ -396,7 +396,9 @@ protected void doClose() throws Exception {
rs = null;
cleanupOnClose();

this.con.setAutoCommit(initialConnectionAutoCommit);
if(this.con != null) {
this.con.setAutoCommit(this.initialConnectionAutoCommit);
}

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

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

if (this.con.getAutoCommit() != this.connectionAutoCommit) {
if (this.connectionAutoCommit != null && this.con.getAutoCommit() != this.connectionAutoCommit) {
this.con.setAutoCommit(this.connectionAutoCommit);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class JdbcCursorItemReaderCommonTests extends AbstractDatabaseItemStreamI
@Override
protected ItemReader<Foo> getItemReader() throws Exception {

JdbcCursorItemReader<Foo> result = new JdbcCursorItemReader<Foo>();
JdbcCursorItemReader<Foo> result = new JdbcCursorItemReader<>();
result.setDataSource(getDataSource());
result.setSql("select ID, NAME, VALUE from T_FOOS");
result.setIgnoreWarnings(true);
Expand Down

0 comments on commit 40db8a7

Please sign in to comment.