fix: align JNI Arrow C Data ownership#10
Merged
Conversation
Contributor
|
@QuakeWang Thanks for your contribution, can you rebase the main? |
Signed-off-by: QuakeWang <wangfuzheng0814@foxmail.com>
7448381 to
5d5075b
Compare
Contributor
Author
@JingsongLi Done :) |
leaves12138
approved these changes
May 20, 2026
leaves12138
left a comment
There was a problem hiding this comment.
Looks good to me. The JNI side now correctly moves ownership of Arrow C Data using from_raw, while Java releases only when the exported structs are still owned on the caller side. The added closed-writer checks also avoid exporting after close. I verified the targeted Java/JNI and Python paths locally.
Contributor
|
+1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Java/JNI writer used inconsistent Arrow C Data ownership semantics.
In the writer open path, Java exported an
ArrowSchemaand released it only after native open returned successfully, while JNI only borrowed the schema. If native open failed, the exported C Data resources could be left unreleased.The write path had the same issue for exported
ArrowArrayandArrowSchema: JNI moved the structs but only cleared the Java-side structs after a successful import, so import failures could leave exported resources owned by Java without being released. This differed from the C FFI path, which clears the source structs immediately after taking ownership.Closed writer paths in Java/Python also exported Arrow C Data before native rejected the write.
Fix
from_raw, clearing the caller structs immediately.finallyonly when the struct still has an active release callback.