From 91e96853a7bcfcf0edce2e89d653186d724491ff Mon Sep 17 00:00:00 2001 From: banseok1216 Date: Wed, 26 Nov 2025 00:31:40 +0900 Subject: [PATCH] Fix incorrect resource closing order in AbstractCursorItemReader#doClose Signed-off-by: banseok1216 --- .../item/database/JdbcCursorItemReader.java | 8 +++++--- .../item/database/StoredProcedureItemReader.java | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/database/JdbcCursorItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/database/JdbcCursorItemReader.java index 271cde659a..05b658b013 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/database/JdbcCursorItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/database/JdbcCursorItemReader.java @@ -144,13 +144,15 @@ protected void openCursor(Connection con) { } /** - * Close the cursor and database connection. - * @param connection to the database + * Releases JDBC resources associated with this reader. + * Closes the PreparedStatement used for the cursor. + * The Connection is not closed here; it is managed by the parent class. + * + * @param connection the active database connection used for the cursor */ @Override protected void cleanupOnClose(Connection connection) { JdbcUtils.closeStatement(this.preparedStatement); - JdbcUtils.closeConnection(connection); } @Override diff --git a/spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/database/StoredProcedureItemReader.java b/spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/database/StoredProcedureItemReader.java index 57ba1bd213..dfd1305060 100644 --- a/spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/database/StoredProcedureItemReader.java +++ b/spring-batch-infrastructure/src/main/java/org/springframework/batch/infrastructure/item/database/StoredProcedureItemReader.java @@ -234,13 +234,15 @@ protected void openCursor(Connection con) { } /** - * Close the cursor and database connection. - * @param connection to the database + * Releases JDBC resources associated with this reader. + * Closes the PreparedStatement used for the cursor. + * The Connection is not closed here; it is managed by the parent class. + * + * @param connection the active database connection used for the cursor */ @Override protected void cleanupOnClose(Connection connection) { JdbcUtils.closeStatement(this.callableStatement); - JdbcUtils.closeConnection(connection); } @Override