Skip to content

Commit edce377

Browse files
manish-qlogiccoryan
authored andcommitted
Removed grpc::StatusCode::OK from the definition of IsTransientFailure (#1203)
This fixes #741.
1 parent 19ba97b commit edce377

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

google/cloud/bigtable/rpc_retry_policy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct SafeGrpcRetry {
3131
// Sometimes we need to use google::protobuf::rpc::Status, in which case this
3232
// is a easier function
3333
static inline bool IsTransientFailure(grpc::StatusCode code) {
34-
return code == grpc::StatusCode::OK or code == grpc::StatusCode::ABORTED or
34+
return code == grpc::StatusCode::ABORTED or
3535
code == grpc::StatusCode::UNAVAILABLE or
3636
code == grpc::StatusCode::DEADLINE_EXCEEDED;
3737
}
@@ -41,7 +41,7 @@ struct SafeGrpcRetry {
4141
return IsTransientFailure(status.error_code());
4242
}
4343
static inline bool IsPermanentFailure(grpc::Status const& status) {
44-
return not IsTransientFailure(status);
44+
return not IsOk(status) and not IsTransientFailure(status);
4545
}
4646
};
4747

google/cloud/bigtable/rpc_retry_policy_test.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ TEST(LimitedTimeRetryPolicy, Simple) {
5959
CheckLimitedTime(tested);
6060
}
6161

62+
/// @test A simple test for grpc::StatusCode::OK is not Permanent Error.
63+
TEST(LimitedTimeRetryPolicy, PermanentFailureCheck) {
64+
bigtable::LimitedTimeRetryPolicy tested(kLimitedTimeTestPeriod);
65+
EXPECT_FALSE(tested.IsPermanentFailure(
66+
grpc::Status(grpc::StatusCode::OK, "No Error")));
67+
EXPECT_FALSE(tested.IsPermanentFailure(CreateTransientError()));
68+
EXPECT_TRUE(tested.IsPermanentFailure(CreatePermanentError()));
69+
}
70+
6271
/// @test Test cloning for LimitedTimeRetryPolicy.
6372
TEST(LimitedTimeRetryPolicy, Clone) {
6473
using namespace google::cloud::testing_util::chrono_literals;

0 commit comments

Comments
 (0)