Repository: servicemix
Updated Branches:
  refs/heads/servicemix-5.0.x 62cd7187f -> 350112d38


SM-2286: Fix Await trait logic to actually check again after the final wait

(Cherry picked from the revision 787232f7f777d16e639b58cb5f5f1339399002c5)


Project: http://git-wip-us.apache.org/repos/asf/servicemix/repo
Commit: http://git-wip-us.apache.org/repos/asf/servicemix/commit/350112d3
Tree: http://git-wip-us.apache.org/repos/asf/servicemix/tree/350112d3
Diff: http://git-wip-us.apache.org/repos/asf/servicemix/diff/350112d3

Branch: refs/heads/servicemix-5.0.x
Commit: 350112d38a415601b60b35edc54e7885345d65b9
Parents: 62cd718
Author: Gert Vanthienen <[email protected]>
Authored: Wed May 7 10:42:08 2014 +0200
Committer: Krzysztof Sobkowiak <[email protected]>
Committed: Wed May 7 18:09:29 2014 +0200

----------------------------------------------------------------------
 .../scala/org/apache/servicemix/itests/Await.scala    | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/servicemix/blob/350112d3/itests/src/test/scala/org/apache/servicemix/itests/Await.scala
----------------------------------------------------------------------
diff --git a/itests/src/test/scala/org/apache/servicemix/itests/Await.scala 
b/itests/src/test/scala/org/apache/servicemix/itests/Await.scala
index 343769f..501de77 100644
--- a/itests/src/test/scala/org/apache/servicemix/itests/Await.scala
+++ b/itests/src/test/scala/org/apache/servicemix/itests/Await.scala
@@ -22,15 +22,19 @@ package org.apache.servicemix.itests
  */
 trait Await {
 
-  val INITIAL_DELAY = 125;
-  val MAXIMUM_DELAY = 8000;
+  val INITIAL_DELAY = 125
+  val MAXIMUM_DELAY = 8000
 
   def await[T](condition: => Option[T]) : Option[T] = await(condition, 
INITIAL_DELAY)
 
   private[this] def await[T](condition: => Option[T], delay: Long) : Option[T] 
=
-    if (delay > MAXIMUM_DELAY) None else condition match {
-      case result @ Some(_) => result
-      case None             => Thread.sleep(delay); await(condition, delay * 
2);
+    condition match {
+      case result@Some(_) => result
+      case None           => if (delay > MAXIMUM_DELAY) None else {
+        // let's sleep for a while and give it another go
+        Thread.sleep(delay)
+        await(condition, delay * 2)
+      }
     }
 
 }

Reply via email to