Fix retry sleep when callable throws exception (#11430)

If the callable throws an exception, we neither increase the retry count nor sleep the thread.
This commit is contained in:
Abhishek Agarwal 2021-07-11 15:06:10 +05:30 committed by GitHub
parent 377b5e708c
commit e228a84d91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -61,17 +61,23 @@ public class ITRetryUtil
if (currentTry > retryCount || callable.call() == expectedValue) {
break;
}
LOG.info(
"Attempt[%d/%d] did not pass: Task %s still not complete. Next retry in %d ms",
currentTry, retryCount, taskMessage, delayInMillis
);
Thread.sleep(delayInMillis);
currentTry++;
}
catch (Exception e) {
// just continue retrying if there is an exception (it may be transient!) but save the last:
lastException = e;
}
LOG.info(
"Attempt[%d/%d] did not pass: Task %s still not complete. Next retry in %d ms",
currentTry, retryCount, taskMessage, delayInMillis
);
try {
Thread.sleep(delayInMillis);
}
catch (InterruptedException e) {
// Ignore
}
currentTry++;
}
if (currentTry > retryCount) {