sahilTakiar commented on a change in pull request #595: HDFS-14304: High lock
contention on hdfsHashMutex in libhdfs
URL: https://github.com/apache/hadoop/pull/595#discussion_r267898627
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/jni_helper.c
##########
@@ -200,43 +185,115 @@ jthrowable invokeMethod(JNIEnv *env, jvalue *retval,
MethType methType,
return NULL;
}
-jthrowable constructNewObjectOfClass(JNIEnv *env, jobject *out, const char
*className,
- const char *ctorSignature, ...)
+jthrowable findClassAndInvokeMethod(JNIEnv *env, jvalue *retval,
+ MethType methType, jobject instObj, const char *className,
+ const char *methName, const char *methSignature, ...)
{
+ jclass cls = NULL;
+ jthrowable jthr = NULL;
+
va_list args;
- jclass cls;
- jmethodID mid;
+ va_start(args, methSignature);
+
+ jthr = validateMethodType(env, methType);
+ if (jthr) {
+ goto done;
+ }
+
+ cls = (*env)->FindClass(env, className);
+ if (!cls) {
+ jthr = getPendingExceptionAndClear(env);
+ goto done;
+ }
+
+ jthr = invokeMethodOnJclass(env, retval, methType, instObj, cls,
+ className, methName, methSignature, args);
+
+done:
+ va_end(args);
+ destroyLocalReference(env, cls);
+ return jthr;
+}
+
+jthrowable invokeMethod(JNIEnv *env, jvalue *retval, MethType methType,
+ jobject instObj, CachedJavaClass class,
+ const char *methName, const char *methSignature, ...)
+{
+ jthrowable jthr;
+
+ va_list args;
+ va_start(args, methSignature);
+
+ jthr = invokeMethodOnJclass(env, retval, methType, instObj,
+ getJclass(class), getClassName(class), methName, methSignature,
+ args);
+
+ va_end(args);
+ return jthr;
+}
+
+static jthrowable constructNewObjectOfJclass(JNIEnv *env,
+ jobject *out, jclass cls, const char *className,
+ const char *ctorSignature, va_list args) {
+ jmethodID mid;
jobject jobj;
jthrowable jthr;
- jthr = globalClassReference(className, env, &cls);
+ jthr = methodIdFromClass(cls, className, "<init>", ctorSignature, INSTANCE,
+ env, &mid);
if (jthr)
return jthr;
- jthr = methodIdFromClass(className, "<init>", ctorSignature,
- INSTANCE, env, &mid);
- if (jthr)
- return jthr;
- va_start(args, ctorSignature);
jobj = (*env)->NewObjectV(env, cls, mid, args);
- va_end(args);
if (!jobj)
return getPendingExceptionAndClear(env);
*out = jobj;
return NULL;
}
-
-jthrowable methodIdFromClass(const char *className, const char *methName,
- const char *methSignature, MethType methType,
- JNIEnv *env, jmethodID *out)
+jthrowable constructNewObjectOfClass(JNIEnv *env, jobject *out,
+ const char *className, const char *ctorSignature, ...)
{
+ va_list args;
jclass cls;
+ jthrowable jthr = NULL;
+
+ cls = (*env)->FindClass(env, className);
+ if (!cls) {
+ jthr = getPendingExceptionAndClear(env);
+ goto done;
Review comment:
Fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]