Repository: servicemix Updated Branches: refs/heads/master f55eaf810 -> d55bc5eda
SM-2286: Fix Await trait logic to actually check again after the final wait (Cherry picked from the commit 787232f7f777d16e639b58cb5f5f1339399002c5) Project: http://git-wip-us.apache.org/repos/asf/servicemix/repo Commit: http://git-wip-us.apache.org/repos/asf/servicemix/commit/d55bc5ed Tree: http://git-wip-us.apache.org/repos/asf/servicemix/tree/d55bc5ed Diff: http://git-wip-us.apache.org/repos/asf/servicemix/diff/d55bc5ed Branch: refs/heads/master Commit: d55bc5eda7c9d7dd8b9dda9b99e2ea6381d3bacf Parents: f55eaf8 Author: Gert Vanthienen <[email protected]> Authored: Wed May 7 10:42:08 2014 +0200 Committer: Krzysztof Sobkowiak <[email protected]> Committed: Wed May 7 18:08:31 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/d55bc5ed/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) + } } }
