From fe5b3f9abb34cca8857905a980e10117caba8feb Mon Sep 17 00:00:00 2001 From: "Terence D. Honles" Date: Wed, 4 Nov 2020 16:33:41 -0800 Subject: [PATCH] ARROW-10499: [C++][Java] Fix ORC Java JNI Crash `OrcStripeReaderJniWrapper::getSchema` previously used `nullptr` for the memory pool parameter to `arrow::ipc::SerializeSchema` to implicitly call `arrow::default_memory_pool()`. As part of https://issues.apache.org/jira/browse/ARROW-10080, a check was placed to fail on `nullptr` being provided. This change removes the check, but also explicitly calls `arrow::default_memory_pool()` which is used elsewhere in the JNI wrapper. --- cpp/src/arrow/io/memory.cc | 1 - cpp/src/jni/orc/jni_wrapper.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/cpp/src/arrow/io/memory.cc b/cpp/src/arrow/io/memory.cc index 1cde5e64e01..361895494e1 100644 --- a/cpp/src/arrow/io/memory.cc +++ b/cpp/src/arrow/io/memory.cc @@ -54,7 +54,6 @@ BufferOutputStream::BufferOutputStream(const std::shared_ptr& b Result> BufferOutputStream::Create( int64_t initial_capacity, MemoryPool* pool) { // ctor is private, so cannot use make_shared - DCHECK_NE(pool, nullptr); auto ptr = std::shared_ptr(new BufferOutputStream); RETURN_NOT_OK(ptr->Reset(initial_capacity, pool)); return ptr; diff --git a/cpp/src/jni/orc/jni_wrapper.cpp b/cpp/src/jni/orc/jni_wrapper.cpp index a3419280e73..e6fc82312d5 100644 --- a/cpp/src/jni/orc/jni_wrapper.cpp +++ b/cpp/src/jni/orc/jni_wrapper.cpp @@ -226,7 +226,7 @@ Java_org_apache_arrow_adapter_orc_OrcStripeReaderJniWrapper_getSchema(JNIEnv* en auto schema = stripe_reader->schema(); - auto maybe_buffer = arrow::ipc::SerializeSchema(*schema, nullptr); + auto maybe_buffer = arrow::ipc::SerializeSchema(*schema, arrow::default_memory_pool()); if (!maybe_buffer.ok()) { return nullptr; }