fix(java/driver/jni): delete JNI local references#4397
Conversation
Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses potential JNI local reference table overflows/leaks in the Java ADBC JNI driver by explicitly deleting JNI local references that can otherwise accumulate during long-running native calls or loops.
Changes:
- Delete the
jstringlocal reference inJniStringView’s destructor after releasing UTF chars. - In
statementExecutePartitions, add a null/exception check afterNewByteArrayand delete the per-iterationjbyteArraylocal reference after passing it to Java.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
zeroshade
left a comment
There was a problem hiding this comment.
is there any way to test this and verify?
|
I believe HotSpot/OpenJDK is not affected by this. https://bugs.openjdk.org/browse/JDK-8297106
It appears neither is Android, after 8.0: https://developer.android.com/ndk/guides/jni-tips
So we would need to test a JVM implementation that isn't derived from OpenJDK, that isn't Android; I believe this is very very few implementations. I can't find any reference to a limit for GraalVM, either. At this point the only other implementation I can think of is CheerpJ, but I don't think we support that in principle in the first place, so... |
Assisted-by: Claude Opus 4.8 noreply@anthropic.com