Skip to content

Commit 04f67a7

Browse files
authored
refactor: prepare for breaking change in Protobuf C++ API. (#14828)
1 parent 335221c commit 04f67a7

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

google/cloud/spanner/internal/status_utils.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "google/cloud/spanner/internal/status_utils.h"
1616
#include "google/cloud/grpc_error_delegate.h"
17+
#include "google/cloud/internal/absl_str_cat_quiet.h"
1718
#include "google/cloud/internal/status_payload_keys.h"
1819
#include "absl/strings/match.h"
1920
#include <google/rpc/error_details.pb.h>
@@ -38,7 +39,8 @@ bool IsSessionNotFound(google::cloud::Status const& status) {
3839
for (google::protobuf::Any const& any : proto.details()) {
3940
if (any.UnpackTo(&resource_info)) {
4041
google::spanner::v1::Session session;
41-
auto session_url = "type.googleapis.com/" + session.GetTypeName();
42+
auto session_url =
43+
absl::StrCat("type.googleapis.com/", session.GetTypeName());
4244
return resource_info.resource_type() == session_url;
4345
}
4446
}

google/cloud/spanner/proto_enum.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ class ProtoEnum {
5757
explicit operator enum_type() const { return v_; }
5858

5959
/// The fully-qualified name of the enum type, scope delimited by periods.
60-
static std::string const& TypeName() { return Descriptor()->full_name(); }
60+
static std::string const& TypeName() {
61+
static std::string const kName(Descriptor()->full_name());
62+
return kName;
63+
}
6164

6265
/// @name Relational operators
6366
///@{

google/cloud/spanner/proto_message.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ class ProtoMessage {
7474

7575
/// The fully-qualified name of the message type, scope delimited by periods.
7676
static std::string const& TypeName() {
77-
return message_type::GetDescriptor()->full_name();
77+
static std::string const kName(message_type::GetDescriptor()->full_name());
78+
return kName;
7879
}
7980

8081
/// @name Relational operators

google/cloud/spanner/testing/status_utils.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "google/cloud/spanner/testing/status_utils.h"
1616
#include "google/cloud/grpc_error_delegate.h"
17+
#include "google/cloud/internal/absl_str_cat_quiet.h"
1718
#include <google/rpc/error_details.pb.h>
1819
#include <google/rpc/status.pb.h>
1920
#include <google/spanner/v1/spanner.pb.h>
@@ -25,7 +26,8 @@ GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
2526

2627
grpc::Status SessionNotFoundRpcError(std::string name) {
2728
google::spanner::v1::Session session;
28-
auto session_url = "type.googleapis.com/" + session.GetTypeName();
29+
auto session_url =
30+
absl::StrCat("type.googleapis.com/", session.GetTypeName());
2931

3032
google::rpc::ResourceInfo resource_info;
3133
resource_info.set_resource_type(session_url);

0 commit comments

Comments
 (0)