This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 0fa2b15eb fix(java/driver/jni): delete JNI local references (#4397)
0fa2b15eb is described below
commit 0fa2b15eb6de883864ef818cd07511bcc2f7c01d
Author: David Li <[email protected]>
AuthorDate: Sun Jun 21 01:28:14 2026 -0700
fix(java/driver/jni): delete JNI local references (#4397)
Assisted-by: Claude Opus 4.8 <[email protected]>
---
java/driver/jni/src/main/cpp/jni_wrapper.cc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/java/driver/jni/src/main/cpp/jni_wrapper.cc
b/java/driver/jni/src/main/cpp/jni_wrapper.cc
index 4afb70aa9..c76e70f0c 100644
--- a/java/driver/jni/src/main/cpp/jni_wrapper.cc
+++ b/java/driver/jni/src/main/cpp/jni_wrapper.cc
@@ -239,6 +239,7 @@ struct JniStringView {
}
env->ReleaseStringUTFChars(jni_string, value);
+ env->DeleteLocalRef(jni_string);
jni_string = nullptr;
}
};
@@ -631,11 +632,15 @@
Java_org_apache_arrow_adbc_driver_jni_impl_NativeAdbc_statementExecutePartitions
for (size_t i = 0; i < partitions.num_partitions; i++) {
size_t length = partitions.partition_lengths[i];
jbyteArray partition = env->NewByteArray(static_cast<jsize>(length));
+ if (partition == nullptr || env->ExceptionCheck()) goto cleanupall;
env->SetByteArrayRegion(partition, 0, static_cast<jsize>(length),
reinterpret_cast<const
jbyte*>(partitions.partitions[i]));
if (env->ExceptionCheck()) goto cleanupall;
env->CallObjectMethod(result, native_result_add_partition, partition);
if (env->ExceptionCheck()) goto cleanupall;
+ // The Java side has a reference now, so free the per-iteration local
+ // reference to avoid overflowing the local reference table
+ env->DeleteLocalRef(partition);
}
} catch (const AdbcException& e) {
e.ThrowJavaException(env);