This is an automated email from the ASF dual-hosted git repository.

xincheng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new d80a29c48c [BUG] #15013 Fix retryInterval in RetryPolicy will never be 
used in RetryUtils (#15014)
d80a29c48c is described below

commit d80a29c48cc5a29b0ef3888d6e2f6aa678742de3
Author: zhihuasu <[email protected]>
AuthorDate: Thu Jan 25 15:07:11 2024 +0800

    [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 <[email protected]>
    Co-authored-by: Rick Cheng <[email protected]>
---
 .../apache/dolphinscheduler/plugin/task/api/utils/RetryUtils.java  | 2 +-
 .../dolphinscheduler/plugin/task/api/utils/RetryUtilsTest.java     | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

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

Reply via email to