Skip to content

Commit

Permalink
Indicate error to client in DoPut if no message sent
Browse files Browse the repository at this point in the history
  • Loading branch information
David Li authored and David Li committed Feb 5, 2019
1 parent cd56782 commit f32c0b2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cpp/src/arrow/flight/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,10 @@ class FlightPutWriter::FlightPutWriterImpl : public ipc::RecordBatchWriter {
// may invoke through vtable (not updated by reinterpret_cast)
if (!custom_writer->grpc::ClientWriter<IpcPayload>::Write(payload,
grpc::WriteOptions())) {
// Stream ended?
return Status::UnknownError("Could not write record batch to stream");
std::stringstream ss;
ss << "Could not write record batch to stream: "
<< rpc_->context.debug_error_string();
return Status::IOError(ss.str());
}
return Status::OK();
}
Expand Down Expand Up @@ -313,7 +315,10 @@ class FlightClient::FlightClientImpl {
descriptor_message.set_data_header(header_buf->ToString());

if (!write_stream->Write(descriptor_message, grpc::WriteOptions())) {
return Status::UnknownError("Could not write initial message to stream");
std::stringstream ss;
ss << "Could not write descriptor and schema to stream: "
<< rpc->context.debug_error_string();
return Status::IOError(ss.str());
}

out->set_stream(std::move(write_stream));
Expand Down
4 changes: 3 additions & 1 deletion cpp/src/arrow/flight/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ class FlightServiceImpl : public FlightService::Service {
return internal::ToGrpcStatus(server_->DoPut(std::move(message_reader)));
}
} else {
return grpc::Status::OK;
return internal::ToGrpcStatus(
Status(StatusCode::Invalid,
"Client provided malformed message or did not provide message"));
}
}

Expand Down

0 comments on commit f32c0b2

Please sign in to comment.