From 1e564b6ad1af95eec3e57fb406f4fce4b508f6ca Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Mon, 29 Apr 2019 16:59:48 -0700 Subject: [PATCH] Fix exponential backoff retry limits. --- .../thoughtcrime/securesms/jobmanager/JobController.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/jobmanager/JobController.java b/src/org/thoughtcrime/securesms/jobmanager/JobController.java index ff6a1be79e..d9f910ba91 100644 --- a/src/org/thoughtcrime/securesms/jobmanager/JobController.java +++ b/src/org/thoughtcrime/securesms/jobmanager/JobController.java @@ -344,7 +344,11 @@ class JobController { } private long calculateNextRunAttemptTime(long currentTime, int nextAttempt, long maxBackoff) { - return currentTime + Math.min((long) Math.pow(2, nextAttempt) * 1000, maxBackoff); + int boundedAttempt = Math.min(nextAttempt, 30); + long exponentialBackoff = (long) Math.pow(2, boundedAttempt) * 1000; + long actualBackoff = Math.min(exponentialBackoff, maxBackoff); + + return currentTime + actualBackoff; } interface Callback {