From a5cc7abe38de81ec9099680f2a308639e19fa730 Mon Sep 17 00:00:00 2001 From: Alan Paxton Date: Wed, 20 Nov 2024 08:59:02 +0000 Subject: [PATCH] Use existing utility to copy jstring --- java/rocksjni/options.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java/rocksjni/options.cc b/java/rocksjni/options.cc index 72b5e1e0b7c..2ae82f90da1 100644 --- a/java/rocksjni/options.cc +++ b/java/rocksjni/options.cc @@ -2311,13 +2311,13 @@ void Java_org_rocksdb_Options_setDailyOffpeakTimeUTC(JNIEnv* env, jclass, jlong jhandle, jstring jtimeutc) { auto* opt = reinterpret_cast(jhandle); - const jsize jtimesz = env->GetStringUTFLength(jtimeutc); - const char* timeutc = env->GetStringUTFChars(jtimeutc, nullptr); - if (env->ExceptionCheck()) { + jboolean has_exception; + auto timeutc = + ROCKSDB_NAMESPACE::JniUtil::copyStdString(env, jtimeutc, &has_exception); + if (has_exception == JNI_TRUE) { return; } - opt->daily_offpeak_time_utc = std::string(timeutc, jtimesz); - env->ReleaseStringUTFChars(jtimeutc, timeutc); + opt->daily_offpeak_time_utc = timeutc; } /*