Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ebe7e237 authored by David Chen's avatar David Chen
Browse files

Fix bug in edge case for statsd anomaly tracking.

Getting a past bucket value will always crash for anomalies
configured to track only the most recent one bucket.

Test: N/A
Change-Id: I2cd1c82fe8ba4cecb4fac21038bb5f04a60c360e
parent 28ff9cee
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -149,6 +149,10 @@ void AnomalyTracker::addBucketToSum(const shared_ptr<DimToValMap>& bucket) {

int64_t AnomalyTracker::getPastBucketValue(const MetricDimensionKey& key,
                                           const int64_t& bucketNum) const {
    if (mNumOfPastBuckets == 0) {
        return 0;
    }

    const auto& bucket = mPastBuckets[index(bucketNum)];
    if (bucket == nullptr) {
        return 0;