Merge "Fix a bug where error count was reset before returning it." into tm-dev am: 1b81993295
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17982495 Change-Id: I560f7f832ddc6dba034c5b8e5c5bc75a1ebe3f6e Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -64,9 +64,10 @@ public class DropboxRateLimiter {
|
||||
}
|
||||
|
||||
if (now - errRecord.getStartTime() > RATE_LIMIT_BUFFER_DURATION) {
|
||||
final int errCount = recentlyDroppedCount(errRecord);
|
||||
errRecord.setStartTime(now);
|
||||
errRecord.setCount(1);
|
||||
return new RateLimitResult(false, recentlyDroppedCount(errRecord));
|
||||
return new RateLimitResult(false, errCount);
|
||||
}
|
||||
|
||||
errRecord.incrementCount();
|
||||
|
||||
@@ -90,6 +90,16 @@ public class DropboxRateLimiterTest {
|
||||
mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated());
|
||||
assertEquals(2,
|
||||
mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated());
|
||||
|
||||
// After 11 seconds the rate limiting buffer will be cleared and rate limiting will stop.
|
||||
mClock.setOffsetMillis(11000);
|
||||
|
||||
// The first call after rate limiting stops will still return the number of dropped events.
|
||||
assertEquals(2,
|
||||
mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated());
|
||||
// The next call should show that the dropped event counter was reset.
|
||||
assertEquals(0,
|
||||
mRateLimiter.shouldRateLimit("tag", "p").droppedCountSinceRateLimitActivated());
|
||||
}
|
||||
|
||||
private static class TestClock implements DropboxRateLimiter.Clock {
|
||||
|
||||
Reference in New Issue
Block a user