You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ks...@apache.org on 2020/04/29 07:02:13 UTC

[arrow] branch master updated: ARROW-8609: [C++] Fix ORC Java JNI crash

This is an automated email from the ASF dual-hosted git repository.

kszucs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 8939b4b  ARROW-8609: [C++] Fix ORC Java JNI crash
8939b4b is described below

commit 8939b4bd446ee406d5225c79d563a27d30fd7d6d
Author: Yuan Zhou <yu...@intel.com>
AuthorDate: Wed Apr 29 09:01:48 2020 +0200

    ARROW-8609: [C++] Fix ORC Java JNI crash
    
    check if arrow buffer is null before passing to the constructor
    
    Signed-off-by: Yuan Zhou <yu...@intel.com>
    
    Closes #7048 from zhouyuan/fix_orc_jni
    
    Authored-by: Yuan Zhou <yu...@intel.com>
    Signed-off-by: Krisztián Szűcs <sz...@gmail.com>
---
 ci/scripts/java_test.sh                                       |  2 +-
 cpp/src/jni/orc/jni_wrapper.cpp                               | 11 +++++++++--
 .../test/java/org/apache/arrow/adapter/orc/OrcReaderTest.java |  2 --
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/ci/scripts/java_test.sh b/ci/scripts/java_test.sh
index 1383388..a30fb00 100755
--- a/ci/scripts/java_test.sh
+++ b/ci/scripts/java_test.sh
@@ -33,7 +33,7 @@ pushd ${source_dir}
 ${mvn} test
 
 if [ "${ARROW_GANDIVA_JAVA}" = "ON" ]; then
-  ${mvn} test -Parrow-jni -pl gandiva -Darrow.cpp.build.dir=${cpp_build_dir}
+  ${mvn} test -Parrow-jni -pl adapter/orc,gandiva -Darrow.cpp.build.dir=${cpp_build_dir}
 fi
 
 if [ "${ARROW_PLASMA}" = "ON" ]; then
diff --git a/cpp/src/jni/orc/jni_wrapper.cpp b/cpp/src/jni/orc/jni_wrapper.cpp
index ce05467..a341928 100644
--- a/cpp/src/jni/orc/jni_wrapper.cpp
+++ b/cpp/src/jni/orc/jni_wrapper.cpp
@@ -276,9 +276,16 @@ Java_org_apache_arrow_adapter_orc_OrcStripeReaderJniWrapper_next(JNIEnv* env,
 
   for (size_t j = 0; j < buffers.size(); ++j) {
     auto buffer = buffers[j];
+    uint8_t* data = nullptr;
+    int size = 0;
+    int64_t capacity = 0;
+    if (buffer != nullptr) {
+      data = (uint8_t*)buffer->data();
+      size = (int)buffer->size();
+      capacity = buffer->capacity();
+    }
     jobject memory = env->NewObject(orc_memory_class, orc_memory_constructor,
-                                    buffer_holder_.Insert(buffer), buffer->data(),
-                                    buffer->size(), buffer->capacity());
+                                    buffer_holder_.Insert(buffer), data, size, capacity);
     env->SetObjectArrayElement(memory_array, j, memory);
   }
 
diff --git a/java/adapter/orc/src/test/java/org/apache/arrow/adapter/orc/OrcReaderTest.java b/java/adapter/orc/src/test/java/org/apache/arrow/adapter/orc/OrcReaderTest.java
index cc95b82..00f47ee 100644
--- a/java/adapter/orc/src/test/java/org/apache/arrow/adapter/orc/OrcReaderTest.java
+++ b/java/adapter/orc/src/test/java/org/apache/arrow/adapter/orc/OrcReaderTest.java
@@ -41,13 +41,11 @@ import org.apache.orc.OrcFile;
 import org.apache.orc.TypeDescription;
 import org.apache.orc.Writer;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.TemporaryFolder;
 
 
-@Ignore
 public class OrcReaderTest {
 
   @Rule