Skip to content

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

Open
lidavidm wants to merge 3 commits into
apache:mainfrom
lidavidm:jni-construction
Open

fix(java/driver/jni): release ADBC resources on Java constructor failure#4396
lidavidm wants to merge 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.

Comment thread java/driver/jni/src/main/cpp/jni_wrapper.cc Outdated
Comment thread java/driver/jni/src/main/cpp/jni_wrapper.cc Outdated
Comment thread java/driver/jni/src/main/cpp/jni_wrapper.cc Outdated
Comment thread java/driver/jni/src/main/cpp/jni_wrapper.cc
Comment thread java/driver/jni/src/main/cpp/jni_wrapper.cc
Comment thread java/driver/jni/src/main/cpp/jni_wrapper.cc
Comment thread java/driver/jni/src/main/cpp/jni_wrapper.cc
Comment thread java/driver/jni/src/main/cpp/jni_wrapper.cc Outdated

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 a review from amoeba June 15, 2026 03:04
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.

2 participants