[automerger] Add bounds checking for transparency lookup am: 53f97a2dd6 am: f171582d41 am: 7c096751ec am: 964b4bc316 am: 1e74900d02 am: cdb13addd3 am: a9b1c97298 am: 5cef228075 am: 98a14c56a8 am: a5ed4c7ef4 am: 7226042d2a
am: 6b2d056043
Change-Id: I49bb68bf9867292cb3380346e361209514a40d9b
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 0000000..fcc567a
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1 @@
+narayan@google.com
diff --git a/common/java/com/android/common/OperationScheduler.java b/common/java/com/android/common/OperationScheduler.java
index 5a8dce8..be92d24 100644
--- a/common/java/com/android/common/OperationScheduler.java
+++ b/common/java/com/android/common/OperationScheduler.java
@@ -183,11 +183,8 @@
(options.backoffIncrementalMillis * errorCount) +
(((long)options.backoffExponentialMillis) << shift);
- // Treat backoff like a moratorium: don't let the backoff
- // time grow too large.
- if (moratoriumTimeMillis > 0 && backoff > moratoriumTimeMillis) {
- backoff = moratoriumTimeMillis;
- }
+ // Treat backoff like a moratorium: don't let the backoff time grow too large.
+ backoff = Math.min(backoff, options.maxMoratoriumMillis);
time = Math.max(time, lastErrorTimeMillis + backoff);
}
diff --git a/common/tests/src/com/android/common/OperationSchedulerTest.java b/common/tests/src/com/android/common/OperationSchedulerTest.java
index 87e2cd8..a25544a 100644
--- a/common/tests/src/com/android/common/OperationSchedulerTest.java
+++ b/common/tests/src/com/android/common/OperationSchedulerTest.java
@@ -155,6 +155,29 @@
assertEquals(beforeError + 84100, scheduler.getNextTimeMillis(options));
}
+ @MediumTest
+ public void testExponentialBackoffBoundedByMoratorium() throws Exception {
+ TimeTravelScheduler scheduler = new TimeTravelScheduler();
+ scheduler.setTriggerTimeMillis(0);
+ scheduler.setEnabledState(true);
+ scheduler.timeMillis = System.currentTimeMillis();
+
+ OperationScheduler.Options options = new OperationScheduler.Options();
+ options.backoffFixedMillis = 100;
+ options.backoffIncrementalMillis = 1000;
+ options.backoffExponentialMillis = 10000;
+ options.maxMoratoriumMillis = 24 * 3600 * 1000;
+
+ for(int i = 1; i < 31; i++) {
+ // report an error - increments the errorCount
+ scheduler.onTransientError();
+ final long nextTime = scheduler.getNextTimeMillis(options);
+ final long timeAfterOperation = System.currentTimeMillis();
+ assertTrue("Backoff is not bounded by max moratorium for iteration " + i,
+ nextTime < timeAfterOperation + options.maxMoratoriumMillis);
+ }
+ }
+
@SmallTest
public void testParseOptions() throws Exception {
OperationScheduler.Options options = new OperationScheduler.Options();
diff --git a/framesequence/OWNERS b/framesequence/OWNERS
new file mode 100644
index 0000000..cd77691
--- /dev/null
+++ b/framesequence/OWNERS
@@ -0,0 +1,2 @@
+ccraik@google.com
+jreck@google.com