Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public void saveDelta() throws IOException {
conf.set("fs.defaultFS",config.fsDefaultFs);
FileSystem fs = FileSystem.get(conf);
Statement stmt = null;
Connection conn = null;
try {
if (config.fromCommitTime == null) {
config.fromCommitTime = inferCommitTime(fs);
Expand All @@ -145,7 +146,7 @@ public void saveDelta() throws IOException {
lastCommitTime = config.fromCommitTime;
}

Connection conn = getConnection();
conn = getConnection();
stmt = conn.createStatement();
// drop the temp table if exists
String tempDbTable = config.tmpDb + "." + config.targetTable + "__" + config.sourceTable;
Expand All @@ -172,6 +173,16 @@ public void saveDelta() throws IOException {
} catch (SQLException e) {
LOG.error("Could not close the resultSet opened ", e);
}
try {
Connection toClose = (conn != null) ? conn : this.connection;
if (toClose != null) {
toClose.close();
}
} catch (SQLException e) {
LOG.error("Could not close the JDBC connection", e);
} finally {
this.connection = null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 nit: the nested finally block here makes the structure confusing — could simplify by moving this.connection = null; outside the try-catch since setting a field to null doesn't throw.

- Generated by an AI agent and may contain mistakes. Please verify any suggestions before applying.

}
}
}

Expand Down
Loading