Reputation: 981
Our client side calls a gRPC server, which ideally should return a MyMessage response object.
But can this MyMessage object be null? or gRPC cannot return null object because if it is null, grpc will throw exception?
Upvotes: 1
Views: 4776
Reputation: 15205
Answering your question, check these Google docs where says:
Note that no Java protocol buffer methods accept or return nulls unless otherwise specified.
So it seems gRPC can't return null. By the way you can take a look to to google.protobuf.empty and reference for Java
You can define your proto like:
import "google/protobuf/empty.proto";
service SomeService {
rpc SomeOperation (google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
Upvotes: 2