Describe the bug, including details regarding any error messages, version, and platform.
When reusing the same JDBC Statement and calling execute(String) multiple times, the Flight SQL JDBC path creates a new prepared statement on each call, but previous prepared handles are not closed before being replaced in client tracking state.
This means only the latest handle is guaranteed to be closed when the statement is closed. On stateful Flight SQL servers, this can leak server-side resources associated with older handles.
Repro
try (Connection connection = DriverManager.getConnection(jdbcUrl, properties);
Statement statement = connection.createStatement()) {
for (int i = 1; i <= n; i++) {
String sql = "SELECT " + i;
boolean isResultSet = statement.execute(sql);
if (isResultSet) {
try (ResultSet rs = statement.getResultSet()) {
while (rs.next()) { /* consume */ }
}
}
}
}
Raised in #1090 (comment)
Describe the bug, including details regarding any error messages, version, and platform.
When reusing the same JDBC Statement and calling execute(String) multiple times, the Flight SQL JDBC path creates a new prepared statement on each call, but previous prepared handles are not closed before being replaced in client tracking state.
This means only the latest handle is guaranteed to be closed when the statement is closed. On stateful Flight SQL servers, this can leak server-side resources associated with older handles.
Repro
Raised in #1090 (comment)