Title: JDBC driver: Closing a Connection does not close its Statement(s), potentially leading to exceptions related to memory leaks · Issue #932 · apache/arrow-java · GitHub
Open Graph Title: JDBC driver: Closing a Connection does not close its Statement(s), potentially leading to exceptions related to memory leaks · Issue #932 · apache/arrow-java
X Title: JDBC driver: Closing a Connection does not close its Statement(s), potentially leading to exceptions related to memory leaks · Issue #932 · apache/arrow-java
Description: Describe the bug, including details regarding any error messages, version, and platform. According to the JDBC specification 4.3 available at https://download.oracle.com/otn-pub/jcp/jdbc-4_3-mrel3-eval-spec/jdbc4.3-fr-spec.pdf, chapter 9...
Open Graph Description: Describe the bug, including details regarding any error messages, version, and platform. According to the JDBC specification 4.3 available at https://download.oracle.com/otn-pub/jcp/jdbc-4_3-mrel3-...
X Description: Describe the bug, including details regarding any error messages, version, and platform. According to the JDBC specification 4.3 available at https://download.oracle.com/otn-pub/jcp/jdbc-4_3-mrel3-...
Opengraph URL: https://github.com/apache/arrow-java/issues/932
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JDBC driver: Closing a Connection does not close its Statement(s), potentially leading to exceptions related to memory leaks","articleBody":"### Describe the bug, including details regarding any error messages, version, and platform.\n\nAccording to the JDBC specification 4.3 available at https://download.oracle.com/otn-pub/jcp/jdbc-4_3-mrel3-eval-spec/jdbc4.3-fr-spec.pdf, chapter 9.6.4.1:\n\n\u003e All Statement objects created from a given\nConnection object will be closed when the close method for the Connection\nobject is called.\n\nIn the Flight SQL JDBC driver closing a Connection does not automatically close the Statement instances obtained via that Connection, making it non compliant with the standard.\n\nDue to this non compliance, on closing a Connection that has a Statement with one or more ResultSet that haven't been fully consumed, we get an exception on `Connection.close()`\n\nCode to reproduce:\n\n`\n try {\n\n // Establish connection\n\n Connection connection = DriverManager.getConnection(jdbcUrl, properties);\n System.out.println(\"Connected to Arrow Flight SQL server\");\n\n Statement stmt = connection.createStatement();\n // my_table needs to have some rows for the bug to manifest itself\n ResultSet rs = stmt.executeQuery(\"SELECT * FROM my_table\");\n // adding this close will eliminate the memory leak, without needing to close the Statement\n // rs.close();\n\n // with stmt.close() we get no memory leak, even if we didn't close the ResultSet\n //stmt.close();\n\n connection.close();\n System.out.println(\"\\nConnection closed\");\n\n } catch (Exception e) {\n System.err.println(\"Error: \" + e.getMessage());\n e.printStackTrace();\n }\n\n`\n\nResulting in the following exception and stack trace\n\n\n```\nDec 14, 2025 5:36:23 PM org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.memory.BaseAllocator close\nSEVERE: Memory was leaked by query. Memory leaked: (32)\nAllocator(flight-client) 0/32/32/9223372036854775807 (res/actual/peak/limit)\n\nError: Failed to clean up client resources.\njava.sql.SQLException: Failed to clean up client resources.\n\tat org.apache.arrow.driver.jdbc.client.ArrowFlightSqlClientHandler.close(ArrowFlightSqlClientHandler.java:269)\n\tat org.apache.arrow.driver.jdbc.ArrowFlightConnection.close(ArrowFlightConnection.java:178)\n\tat MemoryLeak.main(MemoryLeak.java:136)\nCaused by: java.lang.IllegalStateException: Memory was leaked by query. Memory leaked: (32)\nAllocator(flight-client) 0/32/32/9223372036854775807 (res/actual/peak/limit)\n\n\tat org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.memory.BaseAllocator.close(BaseAllocator.java:504)\n\tat org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.FlightClient.close(FlightClient.java:744)\n\tat org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.util.AutoCloseables.close(AutoCloseables.java:97)\n\tat org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.util.AutoCloseables.close(AutoCloseables.java:75)\n\tat org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.flight.sql.FlightSqlClient.close(FlightSqlClient.java:1137)\n\tat org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.util.AutoCloseables.close(AutoCloseables.java:97)\n\tat org.apache.arrow.driver.jdbc.shaded.org.apache.arrow.util.AutoCloseables.close(AutoCloseables.java:75)\n\tat org.apache.arrow.driver.jdbc.client.ArrowFlightSqlClientHandler.close(ArrowFlightSqlClientHandler.java:267)\n\t... 2 more\n\n\n```\n\nWhile a user of the driver with good defensive programming practice would open the ResultSet and/or Statement in a try-with block, the driver should still follow the standard and not produce this Exception.\n\nI believe this bug has been here since the creation of the driver, but I have confirmed that it occurs for both version 17.0.0 and 18.3.0 of the driver.\n\n\n\n\n","author":{"url":"https://github.com/ennuite","@type":"Person","name":"ennuite"},"datePublished":"2025-12-14T17:49:03.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/932/arrow-java/issues/932"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:49b9e62a-22f8-2253-60f1-c4e83e544605 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A3A8:A6D52:41B80F9:5D2C621:6A4FB566 |
| html-safe-nonce | 197d1ae972e2f4ad9f90d6c74bd9f9593a91f058b82a1fbeea6d5a703fc36523 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBM0E4OkE2RDUyOjQxQjgwRjk6NUQyQzYyMTo2QTRGQjU2NiIsInZpc2l0b3JfaWQiOiI3MjIyNjE5ODc1MjIyNDY3OTQyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 407cf3bb0dc4c35b183e41348678f217a09d815e6b7cc84ba49dba30ff62631d |
| hovercard-subject-tag | issue:3727775892 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/apache/arrow-java/932/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a01b138c2764c22d51c9638372ac39734004f9af44359b9888c8cb8d736408fa/apache/arrow-java/issues/932 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a01b138c2764c22d51c9638372ac39734004f9af44359b9888c8cb8d736408fa/apache/arrow-java/issues/932 |
| og:image:alt | Describe the bug, including details regarding any error messages, version, and platform. According to the JDBC specification 4.3 available at https://download.oracle.com/otn-pub/jcp/jdbc-4_3-mrel3-... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ennuite |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| go-import | github.com/apache/arrow-java git https://github.com/apache/arrow-java.git |
| octolytics-dimension-user_id | 47359 |
| octolytics-dimension-user_login | apache |
| octolytics-dimension-repository_id | 893682219 |
| octolytics-dimension-repository_nwo | apache/arrow-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 893682219 |
| octolytics-dimension-repository_network_root_nwo | apache/arrow-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 4b249b445842943ed31549e027f57a8ade9881ed |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width