mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 00:56:31 +08:00
Guard against Flight server returning null listing
This commit is contained in:
1 parent
033734df64
commit
4a5cbaf521
1 file changed
+7
@@ -108,6 +108,9 @@ class FlightServiceImpl : public FlightService::Service {
|
||||
|
||||
template <typename UserType, typename Iterator, typename ProtoType>
|
||||
grpc::Status WriteStream(Iterator* iterator, ServerWriter<ProtoType>* writer) {
|
||||
if (iterator == nullptr) {
|
||||
return grpc::Status(grpc::StatusCode::INTERNAL, "No items to iterate");
|
||||
}
|
||||
// Write flight info to stream until listing is exhausted
|
||||
ProtoType pb_value;
|
||||
std::unique_ptr<UserType> value;
|
||||
@@ -153,6 +156,10 @@ class FlightServiceImpl : public FlightService::Service {
|
||||
GRPC_RETURN_NOT_OK(internal::FromProto(*request, &criteria));
|
||||
}
|
||||
GRPC_RETURN_NOT_OK(server_->ListFlights(&criteria, &listing));
|
||||
if (listing == nullptr) {
|
||||
// Treat null listing as no flights available
|
||||
return grpc::Status::OK;
|
||||
}
|
||||
return WriteStream<FlightInfo>(listing.get(), writer);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user