diff --git a/cpp/core/internal/base_pcp_handler.cc b/cpp/core/internal/base_pcp_handler.cc index 031fbfd6..430caf40 100644 --- a/cpp/core/internal/base_pcp_handler.cc +++ b/cpp/core/internal/base_pcp_handler.cc @@ -518,11 +518,13 @@ Status BasePcpHandler::RequestConnection(ClientProxy* client, } } + Medium channel_medium = + channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM; if (channel == nullptr) { NEARBY_LOGS(INFO) << "Endpoint channel not available: endpoint_id=" << endpoint_id; ProcessPreConnectionInitiationFailure( - client, channel->GetMedium(), endpoint_id, channel.get(), + client, channel_medium, endpoint_id, channel.get(), /* is_incoming = */ false, start_time, connect_impl_result.status, result.get()); return; @@ -546,7 +548,7 @@ Status BasePcpHandler::RequestConnection(ClientProxy* client, NEARBY_LOGS(INFO) << "Failed to send connection request: endpoint_id=" << endpoint_id; ProcessPreConnectionInitiationFailure( - client, channel->GetMedium(), endpoint_id, channel.get(), + client, channel_medium, endpoint_id, channel.get(), /* is_incoming = */ false, start_time, {Status::kEndpointIoError}, result.get()); return; diff --git a/cpp/core/internal/bwu_manager.cc b/cpp/core/internal/bwu_manager.cc index 1a969cc2..f73980fe 100644 --- a/cpp/core/internal/bwu_manager.cc +++ b/cpp/core/internal/bwu_manager.cc @@ -171,9 +171,11 @@ void BwuManager::InitiateBwuForEndpoint(ClientProxy* client, CancelRetryUpgradeAlarm(endpoint_id); auto channel = channel_manager_->GetChannelForEndpoint(endpoint_id); + Medium channel_medium = + channel ? channel->GetMedium() : Medium::UNKNOWN_MEDIUM; client->GetAnalyticsRecorder().OnBandwidthUpgradeStarted( - endpoint_id, channel->GetMedium(), medium_, - proto::connections::INCOMING, client->GetConnectionToken(endpoint_id)); + endpoint_id, channel_medium, medium_, proto::connections::INCOMING, + client->GetConnectionToken(endpoint_id)); if (channel == nullptr) { NEARBY_LOGS(INFO) << "BwuManager couldn't complete the upgrade for endpoint "