diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtils.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtils.java index 1246d85f15..e9672eaad8 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/main/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtils.java +++ b/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 retryFunction(@NonNull Supplier supplier, @NonNull RetryPolicy retryPolicy) { int retryCount = 0; - long retryInterval = 0L; + long retryInterval = retryPolicy.getRetryInterval(); while (true) { try { return supplier.get(); diff --git a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtilsTest.java b/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtilsTest.java index 9f402c81c0..2df0cfe8e5 100644 --- a/dolphinscheduler-task-plugin/dolphinscheduler-task-api/src/test/java/org/apache/dolphinscheduler/plugin/task/api/utils/RetryUtilsTest.java +++ b/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) () -> { + 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); } }