Skip to content

Commit

Permalink
[minor](rpc) Check client before RPC (apache#43626)
Browse files Browse the repository at this point in the history
Check client before RPC
  • Loading branch information
Gabriel39 authored and py023 committed Nov 13, 2024
1 parent 4974a8e commit 97a5fda
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion be/src/runtime/client_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <unordered_map>

#include "common/config.h"
#include "common/exception.h"
#include "common/status.h"
#include "util/hash_util.hpp"
#include "util/metrics.h"
Expand Down Expand Up @@ -189,7 +190,12 @@ class ClientConnection {

inline bool is_alive() { return _client != nullptr; }

T* operator->() const { return _client; }
T* operator->() const {
if (_client == nullptr) {
throw doris::Exception(ErrorCode::INTERNAL_ERROR, "Invalid RPC client!");
}
return _client;
}

private:
ClientCache<T>* _client_cache = nullptr;
Expand Down

0 comments on commit 97a5fda

Please sign in to comment.