1
0
Fork 0

Fix error handling in case ClusterCommResult.result == nullptr (#7356)

This commit is contained in:
Tobias Gödderz 2018-11-26 16:23:44 +01:00 committed by Michael Hackstein
parent 21c832248c
commit 0d5f85e684
1 changed files with 13 additions and 4 deletions

View File

@ -362,13 +362,22 @@ static arangodb::Result cancelBarrier(
DB + database + REPL_BARRIER_API + std::to_string(barrierId), std::string(),
std::unordered_map<std::string, std::string>(), timeout);
// I'm sure that syncRequest cannot return null. But the check doesn't hurt
// and is preferable over a segfault.
TRI_ASSERT(comres != nullptr);
if (comres == nullptr) {
LOG_TOPIC(ERR, Logger::MAINTENANCE)
<< "CancelBarrier: error: syncRequest returned null";
return arangodb::Result{TRI_ERROR_INTERNAL};
}
if (comres->status == CL_COMM_SENT) {
auto result = comres->result;
if (result != nullptr && result->getHttpReturnCode() != 200 &&
result->getHttpReturnCode() != 204) {
auto errorMessage = comres->stringifyErrorMessage();
if (result == nullptr || (result->getHttpReturnCode() != 200 &&
result->getHttpReturnCode() != 204)) {
std::string errorMessage = comres->stringifyErrorMessage();
LOG_TOPIC(ERR, Logger::MAINTENANCE)
<< "CancelBarrier: error" << errorMessage;
<< "CancelBarrier: error" << errorMessage;
return arangodb::Result(TRI_ERROR_INTERNAL, errorMessage);
}
} else {