* Update RetryUtils.java assigned * UT * Update RetryUtilsTest.java --------- Co-authored-by: xiangzihao <460888207@qq.com> Co-authored-by: Rick Cheng <rickchengx@gmail.com>
This commit is contained in:
parent
8abb5e55b7
commit
d80a29c48c
|
|
@ -41,7 +41,7 @@ public class RetryUtils {
|
|||
*/
|
||||
public static <T> T retryFunction(@NonNull Supplier<T> supplier, @NonNull RetryPolicy retryPolicy) {
|
||||
int retryCount = 0;
|
||||
long retryInterval = 0L;
|
||||
long retryInterval = retryPolicy.getRetryInterval();
|
||||
while (true) {
|
||||
try {
|
||||
return supplier.get();
|
||||
|
|
|
|||
|
|
@ -37,6 +37,13 @@ public class RetryUtilsTest {
|
|||
Assertions.fail();
|
||||
});
|
||||
|
||||
long startTime = System.currentTimeMillis();
|
||||
Assertions.assertThrows(RuntimeException.class, () -> RetryUtils.retryFunction((Supplier<Boolean>) () -> {
|
||||
throw new RuntimeException("Test failed function");
|
||||
}, new RetryUtils.RetryPolicy(3, 1000L)));
|
||||
long endTime = System.currentTimeMillis();
|
||||
long elapsedTime = endTime - startTime;
|
||||
Assertions.assertTrue(elapsedTime >= 3000L && elapsedTime < 4000L);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue