Browse Source

[BUG] #15013 Fix retryInterval in RetryPolicy will never be used in RetryUtils (#15014)

* Update RetryUtils.java

assigned

* UT

* Update RetryUtilsTest.java

---------

Co-authored-by: xiangzihao <460888207@qq.com>
Co-authored-by: Rick Cheng <rickchengx@gmail.com>
3.2.1-prepare
zhihuasu 11 months ago committed by GitHub
parent
commit
d80a29c48c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtils.java
  2. 7
      dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtilsTest.java

2
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtils.java

@ -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();

7
dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtilsTest.java

@ -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…
Cancel
Save