This is an automated email from the ASF dual-hosted git repository.
stevenwu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new a0ef46355b Flink: Fix ResultSet resource leak in
JdbcLockFactory.initializeLockTables(). (#13821)
a0ef46355b is described below
commit a0ef46355b809d33b83f3e28eec2795051c4578d
Author: slfan1989 <[email protected]>
AuthorDate: Mon Aug 18 12:02:16 2025 +0800
Flink: Fix ResultSet resource leak in
JdbcLockFactory.initializeLockTables(). (#13821)
---
.../flink/maintenance/api/JdbcLockFactory.java | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git
a/flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java
b/flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java
index c06c584089..f68605accc 100644
---
a/flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java
+++
b/flink/v2.0/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java
@@ -127,21 +127,24 @@ public class JdbcLockFactory implements
TriggerLockFactory {
pool.run(
conn -> {
DatabaseMetaData dbMeta = conn.getMetaData();
- ResultSet tableExists =
+ try (ResultSet rs =
dbMeta.getTables(
null /* catalog name */,
null /* schemaPattern */,
LOCK_TABLE_NAME /* tableNamePattern */,
- null /* types */);
- if (tableExists.next()) {
- LOG.debug("Flink maintenance lock table already exists");
- return true;
+ null /* types */)) {
+ if (rs.next()) {
+ LOG.debug("Flink maintenance lock table already exists");
+ return true;
+ }
}
-
LOG.info("Creating Flink maintenance lock table {}",
LOCK_TABLE_NAME);
- return conn.prepareStatement(CREATE_LOCK_TABLE_SQL).execute();
- });
+ try (PreparedStatement ps =
conn.prepareStatement(CREATE_LOCK_TABLE_SQL)) {
+ ps.execute();
+ }
+ return true;
+ });
} catch (SQLTimeoutException e) {
throw new UncheckedSQLException(
e, "Cannot initialize JDBC table maintenance lock: Query timed out");