You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "xyuanlu (via GitHub)" <gi...@apache.org> on 2023/04/26 04:21:43 UTC

[GitHub] [helix] xyuanlu commented on a diff in pull request #2458: Refactor testHelixViewAggregator

xyuanlu commented on code in PR #2458:
URL: https://github.com/apache/helix/pull/2458#discussion_r1177318694


##########
helix-core/src/test/java/org/apache/helix/TestHelper.java:
##########
@@ -803,19 +803,15 @@ public interface Verifier {
   }
 
   public static boolean verify(Verifier verifier, long timeout) throws Exception {
-    long start = System.currentTimeMillis();
-    do {
-      boolean result = verifier.verify();
-      boolean isTimedout = (System.currentTimeMillis() - start) > timeout;
-      if (result || isTimedout) {
-        if (isTimedout && !result) {
-          LOG.error("verifier time out, consider try longer timeout, stack trace{}",
-              Arrays.asList(Thread.currentThread().getStackTrace()));
-        }
-        return result;
-      }
-      Thread.sleep(50);
-    } while (true);
+    try {
+      with().pollInterval(50, TimeUnit.MILLISECONDS).atMost(timeout, TimeUnit.MILLISECONDS).await()
+          .until(verifier::verify);
+      return verifier.verify();
+    } catch (Exception ex) {
+      LOG.error("verifier time out, consider try longer timeout, stack trace{}",

Review Comment:
   I think when verify times out, it will throw exception and log stack trace. Catch - log and re throw is not needed. 



-- 
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: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org