Skip to content

Commit c6b6b09

Browse files
banseok1216fmbenhassine
authored andcommitted
Fix incorrect resource closing order in AbstractCursorItemReader#doClose
Signed-off-by: banseok1216 <[email protected]>
1 parent 73bbfb0 commit c6b6b09

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,15 @@ protected void openCursor(Connection con) {
144144
}
145145

146146
/**
147-
* Close the cursor and database connection.
148-
* @param connection to the database
147+
* Releases JDBC resources associated with this reader.
148+
* Closes the PreparedStatement used for the cursor.
149+
* The Connection is not closed here; it is managed by the parent class.
150+
*
151+
* @param connection the active database connection used for the cursor
149152
*/
150153
@Override
151154
protected void cleanupOnClose(Connection connection) {
152155
JdbcUtils.closeStatement(this.preparedStatement);
153-
JdbcUtils.closeConnection(connection);
154156
}
155157

156158
@Override

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,15 @@ protected void openCursor(Connection con) {
232232
}
233233

234234
/**
235-
* Close the cursor and database connection.
236-
* @param connection to the database
235+
* Releases JDBC resources associated with this reader.
236+
* Closes the PreparedStatement used for the cursor.
237+
* The Connection is not closed here; it is managed by the parent class.
238+
*
239+
* @param connection the active database connection used for the cursor
237240
*/
238241
@Override
239242
protected void cleanupOnClose(Connection connection) {
240243
JdbcUtils.closeStatement(this.callableStatement);
241-
JdbcUtils.closeConnection(connection);
242244
}
243245

244246
@Override

0 commit comments

Comments
 (0)