marin-ma commented on code in PR #12592:
URL: https://github.com/apache/gluten/pull/12592#discussion_r4335289098
##########
cpp/velox/operators/writer/VeloxColumnarBatchWriter.cc:
##########
@@ -57,6 +57,11 @@ arrow::Status VeloxColumnarBatchWriter::write(const
std::shared_ptr<ColumnarBatc
}
arrow::Status VeloxColumnarBatchWriter::close() {
+ // The writer takes its schema from the first batch, so it is only created
once something has been
+ // written. Closing a writer that never received a batch is a no-op rather
than a null dereference.
+ if (writer_ == nullptr) {
Review Comment:
```
if (writer_) {
writer_->close();
}
return arrow::Status::OK();
```
##########
cpp/velox/jni/JniHashTable.cc:
##########
@@ -45,14 +45,20 @@ void JniHashTableContext::finalize(JNIEnv* env) {
}
}
-jlong JniHashTableContext::callJavaGet(const std::string& id) const {
+std::optional<jlong> JniHashTableContext::callJavaGet(const std::string& id)
const {
+ if (vm_ == nullptr) {
+ return std::nullopt;
+ }
+
JNIEnv* env;
if (vm_->GetEnv(reinterpret_cast<void**>(&env), jniVersion) != JNI_OK) {
throw gluten::GlutenException("JNIEnv was not attached to current thread");
}
const jstring s = env->NewStringUTF(id.c_str());
Review Comment:
Please also add `checkException(env);` here
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]