Skip to content

Commit 68132b9

Browse files
committed
[hotfix] Stabilize integration test (derby)
1 parent a0b6493 commit 68132b9

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

flink-connector-jdbc-core/src/main/java/org/apache/flink/connector/jdbc/core/datastream/source/reader/JdbcSourceSplitReader.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,15 @@ public RecordsWithSplitIds<RecordAndOffset<T>> fetch() throws IOException {
146146
// Check if ResultSet is still open before calling next()
147147
// This is needed for databases like Derby where ResultSet might be closed
148148
// when autocommit is disabled
149-
if (!resultSet.isClosed()) {
150-
hasNextRecordCurrentSplit = resultSet.next();
151-
} else {
149+
try {
150+
if (!resultSet.isClosed()) {
151+
hasNextRecordCurrentSplit = resultSet.next();
152+
} else {
153+
hasNextRecordCurrentSplit = false;
154+
}
155+
} catch (SQLException e) {
156+
// Connection might be closed (e.g., PostgreSQL throws exception on
157+
// isClosed() if connection is closed)
152158
hasNextRecordCurrentSplit = false;
153159
}
154160
} catch (Exception e) {

0 commit comments

Comments
 (0)