Skip to content

Commit cc035c9

Browse files
Fix bad delay code
1 parent 1593376 commit cc035c9

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

google-cloud-contrib/google-cloud-nio/src/main/java/com/google/cloud/storage/contrib/nio/CloudStorageReadChannel.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,8 @@ private static boolean isReopenable(Throwable exs) {
159159
}
160160

161161
private void sleepForAttempt(int attempt) {
162-
long firstdelay = 1000;
163-
long maxDelay = 120_000;
164-
// exponential backoff
165-
long delay = firstdelay * Math.min(1 << attempt, maxDelay);
162+
// exponential backoff, but let's bound it around 2min.
163+
long delay = 1000L * (1L << Math.min(attempt, 7));
166164
try {
167165
Thread.sleep(delay);
168166
} catch (InterruptedException iex) {

0 commit comments

Comments
 (0)