voonhous commented on code in PR #17677:
URL: https://github.com/apache/hudi/pull/17677#discussion_r2643414768


##########
hudi-flink-datasource/hudi-flink/src/test/java/org/apache/hudi/utils/TestUtils.java:
##########
@@ -157,4 +159,14 @@ public static String 
amendCompletionTimeToLatest(HoodieTableMetaClient metaClien
     Files.move(sourcePath, newFilePath);
     return newCompletionTime;
   }
+
+  public static boolean waitUntil(BooleanSupplier condition, int 
timeoutSeconds) throws InterruptedException {
+    for (int i = 0; i < timeoutSeconds; i++) {
+      if (condition.getAsBoolean()) {
+        return true;
+      }
+      TimeUnit.SECONDS.sleep(1);
+    }
+    return false;
+  }

Review Comment:
   ```suggestion
   /**
    * Waits for a condition to be met within a specific timeout.
    *
    * @param condition      The condition to poll.
    * @param timeoutSeconds Maximum time to wait in seconds.
    */
   public static boolean waitUntil(BooleanSupplier condition, int 
timeoutSeconds) {
     long limit = System.currentTimeMillis() + (timeoutSeconds * 1000L);
     while (System.currentTimeMillis() < limit) {
       if (condition.getAsBoolean()) {
         return true;
       }
       TimeUnit.MILLISECONDS.sleep(500);
     }
     return false;
   }
   ```
   
   Nit: use while loop + epoch comparison



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to