diff --git a/test/jdk/jni/nullCaller/exeNullCallerTest.cpp b/test/jdk/jni/nullCaller/exeNullCallerTest.cpp index 3d79befd94156..260a1edb9b4cd 100644 --- a/test/jdk/jni/nullCaller/exeNullCallerTest.cpp +++ b/test/jdk/jni/nullCaller/exeNullCallerTest.cpp @@ -55,9 +55,11 @@ void getBundle(JNIEnv* env) { // msg = b.getString("message"); jstring msg = (jstring) m_ResourceBundle_getString.callReturnNotNull(b, env->NewStringUTF("message")); - if (std::string("Hello!") != env->GetStringUTFChars(msg, NULL)) { + const char* chars = env->GetStringUTFChars(msg, nullptr); + if (std::string("Hello!") != chars) { emitErrorMessageAndExit("Bundle didn't contain expected content"); } + env->ReleaseStringUTFChars(msg, chars); // ResourceBundle.clearCache() m_ResourceBundle_clearCache.callVoidMethod();