Skip to content

MINOR: Close prepared handles on Statement reuse - #46

Open
xborder wants to merge 2 commits into
mainfrom
codex/gh-1129-statement-handle-leak
Open

xborder wants to merge 2 commits into
mainfrom
codex/gh-1129-statement-handle-leak

Conversation

@xborder

@xborder xborder commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Summary

on Statement.execute(sql)
  replacement = prepare(sql, existingJdbcHandle)
  try
    close previous server prepared handle
  catch closeFailure
    close replacement
    suppress replacement-close failure
    rethrow closeFailure
  execute replacement

This releases the old handle when a JDBC Statement runs again. If closing the old handle fails, it also attempts to release the replacement and keeps the old close error as the main error.

Related upstream issue: apache/arrow-java#1129.

Evidence

  • Before: Two executions created two server handles. Statement.close() closed only the last handle.
    After: testExecuteMultipleTimesClosesAllPreparedStatements checks for two create actions and two close actions.
  • testExecuteAttemptsToCloseReplacementWhenPreviousCloseFails checks that cleanup runs and keeps the original error, with cleanup failure suppressed.
  • ArrowFlightStatementExecuteTest: 13 passed. Spotless and Checkstyle passed.

Merge Danger

Door: Two-way.

Blast Radius: Low

Close the previous server-side handle after building a replacement for repeated Statement.execute(String) calls.
@xborder xborder added the bug-fix Bug fixes label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant