Fix incompatibility with Protobuf 22.x.
In version 22.x, the JSON conversion functions return
absl::Status, which is marked nodiscard. Check the ok() function
before printing the output.
Bug: 329747255
Test: presubmit
Change-Id: I46e2f20a26953dc6501f51daecc1a56547a326ab
diff --git a/src/result.cpp b/src/result.cpp
index 0726d34..e0b82a6 100644
--- a/src/result.cpp
+++ b/src/result.cpp
@@ -416,10 +416,11 @@
google::protobuf::util::JsonPrintOptions options;
options.add_whitespace = true;
- google::protobuf::util::MessageToJsonString(pb, &json, options);
-
- std::ostream pb_stream(std::cout.rdbuf());
- pb_stream << json << std::endl;
+ auto status = google::protobuf::util::MessageToJsonString(pb, &json, options);
+ if (status.ok()) {
+ std::ostream pb_stream(std::cout.rdbuf());
+ pb_stream << json << std::endl;
+ }
}
std::unique_ptr<Result> Result::FromPb(const dittosuiteproto::Result& pb) {