ctubbsii commented on a change in pull request #1037: Switch to leader latch WIP
URL: https://github.com/apache/fluo/pull/1037#discussion_r192927526
 
 

 ##########
 File path: 
modules/integration/src/test/java/org/apache/fluo/integration/impl/OracleIT.java
 ##########
 @@ -318,14 +322,8 @@ public void threadFailoverTest() throws Exception {
     oserver3.close();
   }
 
-  private void sleepWhileConnected(OracleServer oserver) throws 
InterruptedException {
-    while (oserver.isConnected()) {
-      Thread.sleep(100);
-    }
-  }
-
-  private void sleepUntilConnected(OracleServer oserver) throws 
InterruptedException {
-    while (!oserver.isConnected()) {
+  private void sleepWhile(Supplier<Boolean> condition) throws 
InterruptedException {
+    while (condition.get()) {
 
 Review comment:
   I like how you changed this to a supplier, but I also liked the readability 
of the `sleepUntil` method name.
   
   You could add it back as:
   
   ```java
   private void sleepUntil(Supplier<Boolean> condition) throws 
InterruptedException {
     sleepWhile(() -> !condition.get());
   }
   ```
   
   And then, all your statements would like like one of these two:
   
   ```java
   sleepWhile(oserver::isConnected());
   sleepUntil(oserver::isConnected());
   ```
   
   That would remove all the excess `() ->` stuff a bit, too.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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

Reply via email to