diff --git a/examples/cpp/helloworld/BUILD b/examples/cpp/helloworld/BUILD index 463dd6f495b..3c01b6ce1c3 100644 --- a/examples/cpp/helloworld/BUILD +++ b/examples/cpp/helloworld/BUILD @@ -35,6 +35,7 @@ cc_binary( "//examples/protos:helloworld_cc_grpc", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:check", ], ) @@ -47,6 +48,7 @@ cc_binary( "//examples/protos:helloworld_cc_grpc", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:check", ], ) @@ -97,6 +99,7 @@ cc_binary( "//examples/protos:helloworld_cc_grpc", "@com_google_absl//absl/flags:flag", "@com_google_absl//absl/flags:parse", + "@com_google_absl//absl/log:check", "@com_google_absl//absl/strings:str_format", ], ) diff --git a/examples/cpp/helloworld/CMakeLists.txt b/examples/cpp/helloworld/CMakeLists.txt index 60541aa0f95..73ad4877483 100644 --- a/examples/cpp/helloworld/CMakeLists.txt +++ b/examples/cpp/helloworld/CMakeLists.txt @@ -52,6 +52,7 @@ add_library(hw_grpc_proto ${hw_proto_srcs} ${hw_proto_hdrs}) target_link_libraries(hw_grpc_proto + absl::check ${_REFLECTION} ${_GRPC_GRPCPP} ${_PROTOBUF_LIBPROTOBUF}) @@ -64,6 +65,7 @@ foreach(_target add_executable(${_target} "${_target}.cc") target_link_libraries(${_target} hw_grpc_proto + absl::check absl::flags absl::flags_parse ${_REFLECTION} diff --git a/examples/cpp/helloworld/greeter_async_client.cc b/examples/cpp/helloworld/greeter_async_client.cc index d37c82bcd3f..5d2fd7eb303 100644 --- a/examples/cpp/helloworld/greeter_async_client.cc +++ b/examples/cpp/helloworld/greeter_async_client.cc @@ -22,6 +22,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/check.h" #include #include @@ -81,14 +82,14 @@ class GreeterClient { // Block until the next result is available in the completion queue "cq". // The return value of Next should always be checked. This return value // tells us whether there is any kind of event or the cq_ is shutting down. - GPR_ASSERT(cq.Next(&got_tag, &ok)); + CHECK(cq.Next(&got_tag, &ok)); // Verify that the result from "cq" corresponds, by its tag, our previous // request. - GPR_ASSERT(got_tag == (void*)1); + CHECK_EQ(got_tag, (void*)1); // ... and that the request was completed successfully. Note that "ok" // corresponds solely to the request for updates introduced by Finish(). - GPR_ASSERT(ok); + CHECK(ok); // Act upon the status of the actual RPC. if (status.ok()) { diff --git a/examples/cpp/helloworld/greeter_async_client2.cc b/examples/cpp/helloworld/greeter_async_client2.cc index 62f91b52a0e..65f18cb1014 100644 --- a/examples/cpp/helloworld/greeter_async_client2.cc +++ b/examples/cpp/helloworld/greeter_async_client2.cc @@ -23,6 +23,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/check.h" #include #include @@ -88,7 +89,7 @@ class GreeterClient { // Verify that the request was completed successfully. Note that "ok" // corresponds solely to the request for updates introduced by Finish(). - GPR_ASSERT(ok); + CHECK(ok); if (call->status.ok()) std::cout << "Greeter received: " << call->reply.message() << std::endl; diff --git a/examples/cpp/helloworld/greeter_async_server.cc b/examples/cpp/helloworld/greeter_async_server.cc index 21cbdf227fa..957d560c9bc 100644 --- a/examples/cpp/helloworld/greeter_async_server.cc +++ b/examples/cpp/helloworld/greeter_async_server.cc @@ -23,6 +23,7 @@ #include "absl/flags/flag.h" #include "absl/flags/parse.h" +#include "absl/log/check.h" #include "absl/strings/str_format.h" #include @@ -116,7 +117,7 @@ class ServerImpl final { status_ = FINISH; responder_.Finish(reply_, Status::OK, this); } else { - GPR_ASSERT(status_ == FINISH); + CHECK_EQ(status_, FINISH); // Once in the FINISH state, deallocate ourselves (CallData). delete this; } @@ -158,8 +159,8 @@ class ServerImpl final { // memory address of a CallData instance. // The return value of Next should always be checked. This return value // tells us whether there is any kind of event or cq_ is shutting down. - GPR_ASSERT(cq_->Next(&tag, &ok)); - GPR_ASSERT(ok); + CHECK(cq_->Next(&tag, &ok)); + CHECK(ok); static_cast(tag)->Proceed(); } } diff --git a/examples/cpp/interceptors/BUILD b/examples/cpp/interceptors/BUILD index b6c78395c53..31a3e2bf77d 100644 --- a/examples/cpp/interceptors/BUILD +++ b/examples/cpp/interceptors/BUILD @@ -24,6 +24,7 @@ cc_binary( deps = [ "//:grpc++", "//examples/protos:keyvaluestore", + "@com_google_absl//absl/log:check", ], ) diff --git a/examples/cpp/interceptors/CMakeLists.txt b/examples/cpp/interceptors/CMakeLists.txt index 8987b2b5366..38b7c83c570 100644 --- a/examples/cpp/interceptors/CMakeLists.txt +++ b/examples/cpp/interceptors/CMakeLists.txt @@ -52,6 +52,7 @@ add_library(kvs_grpc_proto ${kvs_proto_srcs} ${kvs_proto_hdrs}) target_link_libraries(kvs_grpc_proto + absl::check ${_REFLECTION} ${_GRPC_GRPCPP} ${_PROTOBUF_LIBPROTOBUF}) @@ -59,6 +60,7 @@ target_link_libraries(kvs_grpc_proto # client add_executable(client "client.cc" "caching_interceptor.h") target_link_libraries(client + absl::check kvs_grpc_proto ${_REFLECTION} ${_GRPC_GRPCPP} @@ -67,6 +69,7 @@ target_link_libraries(client # server add_executable(server "server.cc") target_link_libraries(server + absl::check kvs_grpc_proto ${_REFLECTION} ${_GRPC_GRPCPP} diff --git a/examples/cpp/interceptors/caching_interceptor.h b/examples/cpp/interceptors/caching_interceptor.h index a91a48a8078..b461524f6f4 100644 --- a/examples/cpp/interceptors/caching_interceptor.h +++ b/examples/cpp/interceptors/caching_interceptor.h @@ -18,6 +18,8 @@ #include +#include "absl/log/check.h" + #include #ifdef BAZEL_BUILD @@ -62,10 +64,9 @@ class CachingInterceptor : public grpc::experimental::Interceptor { keyvaluestore::Request req_msg; auto* buffer = methods->GetSerializedSendMessage(); auto copied_buffer = *buffer; - GPR_ASSERT( - grpc::SerializationTraits::Deserialize( - &copied_buffer, &req_msg) - .ok()); + CHECK(grpc::SerializationTraits::Deserialize( + &copied_buffer, &req_msg) + .ok()); requested_key = req_msg.key(); }