Fix NPE in NetworkMetrics

addTcpStatsResult() in NetworkMetrics was not checking for the nullness
of the pendingSummary object and trying to add stats regardless.

This patch fixes addTcpStatsResult() so that it populates pendingSummary
if necessary, similarly to addConnectResult() and addDnsResult()

Bug: 73825228
Test: runtest frameworks-net
Change-Id: I616a4be0e6e5920bd2f5c58292fea769bd516df7
This commit is contained in:
Hugo Benichi
2018-02-24 08:01:30 +09:00
parent 1ea3d9411a
commit e73486bf24

View File

@@ -98,6 +98,9 @@ public class NetworkMetrics {
/** Accumulate a single netd sock_diag poll result reported by netd. */
public void addTcpStatsResult(int sent, int lost, int rttUs, int sentAckDiffMs) {
if (pendingSummary == null) {
pendingSummary = new Summary(netId, transports);
}
pendingSummary.tcpLossRate.count(lost, sent);
pendingSummary.roundTripTimeUs.count(rttUs);
pendingSummary.sentAckTimeDiffenceMs.count(sentAckDiffMs);