Skip to content

Commit 76dfe36

Browse files
committed
Ensure sufficient space for local references
1 parent cd5b0d4 commit 76dfe36

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

java/rocksjni/env.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ jobjectArray Java_org_rocksdb_Env_getThreadList(JNIEnv* env, jclass,
137137

138138
// object[]
139139
const jsize len = static_cast<jsize>(thread_status.size());
140+
if (env->EnsureLocalCapacity((len * 2) + 1) != JNI_OK) {
141+
// out of memory
142+
env->ExceptionClear();
143+
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(env, "Insufficient JNI local references for thread list");
144+
return nullptr;
145+
}
140146
jobjectArray jthread_status = env->NewObjectArray(
141147
len, ROCKSDB_NAMESPACE::ThreadStatusJni::getJClass(env), nullptr);
142148
if (jthread_status == nullptr) {

java/rocksjni/transaction.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ void txn_write_kv_parts_helper(JNIEnv* env,
673673
// in order to avoid the local reference limit.
674674
// The user needs to be a aware that there is a limit to the number of parts
675675
// which can be gathered.
676-
if (env->EnsureLocalCapacity(jkey_parts_len + jvalue_parts_len) != 0) {
676+
if (env->EnsureLocalCapacity(jkey_parts_len + jvalue_parts_len) != JNI_OK) {
677677
// no space for all the jobjects we store up
678678
env->ExceptionClear();
679679
ROCKSDB_NAMESPACE::RocksDBExceptionJni::ThrowNew(

0 commit comments

Comments
 (0)