Skip to content

fix(java/driver/jni): release ADBC resources on Java constructor failure - #4396

Merged
lidavidm merged 3 commits into
apache:mainfrom
lidavidm:jni-construction
Jun 20, 2026
Merged

lidavidm merged 3 commits into
apache:mainfrom
lidavidm:jni-construction

Conversation

@lidavidm

Copy link
Copy Markdown
Member

When NewObject fails, explicitly call AdbcFooRelease or foo->release instead of implicitly leaking the ADBC handle.

Assisted-by: Claude Opus 4.8 noreply@anthropic.com

…lure

When NewObject fails, explicitly call AdbcFooRelease or foo->release
instead of implicitly leaking the ADBC handle.

Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Java JNI driver against native resource leaks when constructing Java “native handle/result” objects fails, ensuring ADBC/Arrow C resources are explicitly released instead of being silently leaked.

Changes:

  • Add explicit Adbc*Release calls on failure paths in openDatabase, openConnection, and openStatement (notably when NewObject fails).
  • Add failure-safe cleanup in MakeNativeQueryResult / MakeNativeSchemaResult to release ArrowArrayStream / ArrowSchema when Java object construction fails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@lidavidm
lidavidm marked this pull request as ready for review June 15, 2026 03:04
@lidavidm
lidavidm requested review from amoeba and zeroshade June 15, 2026 03:04
@lidavidm
lidavidm merged commit 6efc6b6 into apache:main Jun 20, 2026
19 of 21 checks passed
@lidavidm
lidavidm deleted the jni-construction branch June 20, 2026 11:45
@lidavidm lidavidm added this to the ADBC Libraries 24 milestone Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants