[lb_policy] Remove 2 nullptr checks for `endpoint_list_` in round_robin and wrr (#37685)

Closes #37673

Closes #37685

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37685 from yijiem:nullptr-check-lb fecac2b751
PiperOrigin-RevId: 677872993
pull/37790/head
Yijie Ma 2 months ago committed by Copybara-Service
parent cdbc99d811
commit d1fddda871
  1. 8
      src/core/load_balancing/round_robin/round_robin.cc
  2. 8
      src/core/load_balancing/weighted_round_robin/weighted_round_robin.cc

@ -361,14 +361,10 @@ void RoundRobin::RoundRobinEndpointList::
(num_ready_ > 0 && AllEndpointsSeenInitialState()) ||
num_transient_failure_ == size())) {
if (GRPC_TRACE_FLAG_ENABLED(round_robin)) {
const std::string old_counters_string =
round_robin->endpoint_list_ != nullptr
? round_robin->endpoint_list_->CountersString()
: "";
LOG(INFO) << "[RR " << round_robin << "] swapping out child list "
<< round_robin->endpoint_list_.get() << " ("
<< old_counters_string << ") in favor of " << this << " ("
<< CountersString() << ")";
<< round_robin->endpoint_list_->CountersString()
<< ") in favor of " << this << " (" << CountersString() << ")";
}
round_robin->endpoint_list_ =
std::move(round_robin->latest_pending_endpoint_list_);

@ -947,12 +947,10 @@ void WeightedRoundRobin::WrrEndpointList::
(num_ready_ > 0 && AllEndpointsSeenInitialState()) ||
num_transient_failure_ == size())) {
if (GRPC_TRACE_FLAG_ENABLED(weighted_round_robin_lb)) {
const std::string old_counters_string =
wrr->endpoint_list_ != nullptr ? wrr->endpoint_list_->CountersString()
: "";
LOG(INFO) << "[WRR " << wrr << "] swapping out endpoint list "
<< wrr->endpoint_list_.get() << " (" << old_counters_string
<< ") in favor of " << this << " (" << CountersString() << ")";
<< wrr->endpoint_list_.get() << " ("
<< wrr->endpoint_list_->CountersString() << ") in favor of "
<< this << " (" << CountersString() << ")";
}
wrr->endpoint_list_ = std::move(wrr->latest_pending_endpoint_list_);
}

Loading…
Cancel
Save