linzch3 opened a new pull request, #1441: URL: https://github.com/apache/arrow-java/pull/1441
## What's Changed `AvaticaParameterBinder` creates the parameter `VectorSchemaRoot` and fills it one value at a time. It only hands the root to the prepared statement (`setParameters`) after every value binds. If a later value throws (for example, NULL into a non-nullable parameter, or a type mismatch), the memory for the values bound before it is never released. Closing the statement does not free it, and closing the connection later fails with `Memory was leaked by query`. This change closes the root before rethrowing, but only while the binder still owns it. After a successful `bind` hands the root to the statement (for example, an earlier row of `executeBatch`), the statement owns it. It is left alone, so the statement can still close it. Tests: the new `AvaticaParameterBinderTest` uses a stub prepared statement with two non-nullable parameters: - A valid value followed by NULL, repeated three times. Before the fix, this left 16392 bytes allocated after each statement closed. Now it leaves 0. - A valid value followed by a type mismatch. This left 16388 bytes before the fix; now it leaves 0. - A failed second batch row after the first row was handed off. The statement keeps a usable root, and closing it frees everything. I ran `mvn verify -pl flight/flight-sql-jdbc-core` locally on JDK 21 (1258 tests, including spotless and checkstyle), and it passed. This change was prepared with an AI coding assistant (Grok Bot), which wrote the fix and the tests. I checked the ownership reasoning against `FlightSqlClient.PreparedStatement.setParameters`/`close` and ran the tests locally before and after the fix. Closes #1439. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
