limbooverlambda commented on code in PR #2458:
URL: https://github.com/apache/helix/pull/2458#discussion_r1178214977
##########
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:
In the previous implementation it looks like upon timeout, a false is
returned upon the expiration of the timeout (preceded by a log err indicating
that the verification has timed out). In this iteration, we are throwing the
exception back but the catch-rethrow is just to render the log line.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]