servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ksobkow...@apache.org
Subject git commit: SM-2286: Fix Await trait logic to actually check again after the final wait
Date Wed, 07 May 2014 16:07:24 GMT
Repository: servicemix
Updated Branches:
  refs/heads/servicemix-5.1.x e1f1a1b4b -> 787232f7f


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


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

Branch: refs/heads/servicemix-5.1.x
Commit: 787232f7f777d16e639b58cb5f5f1339399002c5
Parents: e1f1a1b
Author: Gert Vanthienen <gertv@apache.org>
Authored: Wed May 7 10:42:08 2014 +0200
Committer: Krzysztof Sobkowiak <krzys.sobkowiak@gmail.com>
Committed: Wed May 7 16:14:59 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/787232f7/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)
+      }
     }
 
 }


Mime
View raw message