dcapwell commented on a change in pull request #470: CASSANDRA-15630 fix 
testSerializeError
URL: https://github.com/apache/cassandra/pull/470#discussion_r393968395
 
 

 ##########
 File path: test/unit/org/apache/cassandra/net/ConnectionUtils.java
 ##########
 @@ -240,6 +247,31 @@ private void doCheck(FailCheck testAndFailCheck)
         }
     }
 
+    /**
+     * Perform the {@param assertion} within the specified duration repeatly 
until a success.
+     * Otherwise, it times out and re-throws the {@link AssertionError} from 
the {@param assertion}.
+     */
+    private static void longCheck(Runnable assertion, long timeout, TimeUnit 
timeUnit)
+    {
+        long startNano = System.nanoTime();
+        for (;;)
+        {
+            try
+            {
+                assertion.run();
+                return;
+            }
+            catch (AssertionError e)
+            {
+                long elapsedNano = System.nanoTime() - startNano;
+                if (elapsedNano > timeUnit.toNanos(timeout))
 
 Review comment:
   sorry I didn't comment sooner, I left it in my example; it would be best to 
compute `timeUnit.toNanos(timeout)` once outside the loop

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to