Skip to content

Commit

Permalink
Fix the crash caused by a nullptr variable (#5100)
Browse files Browse the repository at this point in the history
* remove nullptr.

* fix another line.

* revise codes.
  • Loading branch information
xtcyclist authored Dec 26, 2022
1 parent 3fa3c5d commit a8fee05
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/clients/storage/StorageClientBase-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,20 @@ folly::Future<StatusOr<Response>> StorageClientBase<ClientType, ClientManagerTyp

using TransportException = apache::thrift::transport::TTransportException;
auto ex = exWrapper.get_exception<TransportException>();
if (ex && ex->getType() == TransportException::TIMED_OUT) {
LOG(ERROR) << "Request to " << host << " time out: " << ex->what();
if (ex) {
if (ex->getType() == TransportException::TIMED_OUT) {
LOG(ERROR) << "Request to " << host << " time out: " << ex->what();
return Status::Error("RPC failure in StorageClient with timeout: %s", ex->what());
} else {
LOG(ERROR) << "Request to " << host << " failed: " << ex->what();
return Status::Error("RPC failure in StorageClient: %s", ex->what());
}
} else {
auto partsId = getReqPartsId(request);
invalidLeader(spaceId, partsId);
LOG(ERROR) << "Request to " << host << " failed: " << ex->what();
LOG(ERROR) << "Request to " << host << " failed.";
return Status::Error("RPC failure in StorageClient.");
}
return Status::Error("RPC failure in StorageClient, probably timeout: %s", ex->what());
});
}

Expand Down

0 comments on commit a8fee05

Please sign in to comment.