toddlipcon commented on a change in pull request #597: HDFS-3246: pRead
equivalent for direct read path
URL: https://github.com/apache/hadoop/pull/597#discussion_r273628261
##########
File path:
hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/hdfs.c
##########
@@ -985,6 +1011,49 @@ int hdfsStreamBuilderSetDefaultBlockSize(struct
hdfsStreamBuilder *bld,
return 0;
}
+static int hdfsHasStreamCapability(jobject jFile,
+ const char *capability) {
+ int ret = 0;
+ jthrowable jthr = NULL;
+ jvalue jVal;
+ jstring jCapabilityString = NULL;
+
+ /* Get the JNIEnv* corresponding to current thread */
+ JNIEnv* env = getJNIEnv();
+ if (env == NULL) {
+ errno = EINTERNAL;
+ return 0;
+ }
+
+ jthr = newJavaStr(env, capability, &jCapabilityString);
+ if (jthr) {
+ ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
+ "hdfsHasStreamCapability(%s): newJavaStr", capability);
+ goto done;
+ }
+ jthr = invokeMethod(env, &jVal, INSTANCE, jFile,
+ JC_FS_DATA_INPUT_STREAM, "hasCapability", "(Ljava/lang/String;)Z",
+ jCapabilityString);
+ if (jthr) {
+ ret = printExceptionAndFree(env, jthr, PRINT_EXC_ALL,
+ "hdfsHasStreamCapability(%s): FSDataInputStream#hasCapability",
+ capability);
+ goto done;
+ }
+
+done:
+ destroyLocalReference(env, jthr);
+ destroyLocalReference(env, jCapabilityString);
+ if (ret) {
+ errno = ret;
+ return 0;
Review comment:
seems a little weird to return 0 but also set errno here -- I see that
you're doing it because you want to fall back to false on error, but then maybe
errno should not be set
----------------------------------------------------------------
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]