Skip to content

Commit b727c66

Browse files
authored
Reclaim the statement variable to avoid executing stale statements in the subsequent new test case (#18001)
* Reclaim the statement variable to avoid executing stale statements in the subsequent new test case. * Don't affect the connection closing any more * Fix
1 parent b6c217a commit b727c66

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • integration-test/src/test/java/org/apache/iotdb/db/it/utils

integration-test/src/test/java/org/apache/iotdb/db/it/utils/TestUtils.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1205,14 +1205,24 @@ public static boolean tryExecuteNonQueriesWithRetry(
12051205
}
12061206
return true;
12071207
} catch (SQLException e) {
1208+
if (statement != null) {
1209+
try {
1210+
statement.close();
1211+
} catch (Exception ex) {
1212+
// ignore
1213+
} finally {
1214+
statement = null;
1215+
}
1216+
}
12081217
// the default connection should be closed by the upper level
12091218
// while the local connection should be closed here
12101219
if (connectionToUse == localConnection && localConnection != null) {
12111220
try {
12121221
localConnection.close();
1213-
localConnection = null;
12141222
} catch (SQLException ex) {
12151223
// ignore
1224+
} finally {
1225+
localConnection = null;
12161226
}
12171227
}
12181228
connectionToUse = null;

0 commit comments

Comments
 (0)