Switched to FutureTimeoutException for Future.apply/Future.get

This commit is contained in:
Viktor Klang 2011-03-22 22:20:32 +01:00
parent 65f24877b3
commit f74151a67f
2 changed files with 6 additions and 4 deletions

View file

@ -205,10 +205,7 @@ sealed trait Future[+T] {
* and will throw a java.util.concurrent.TimeoutException if there is no result
* within the Futures timeout
*/
def apply(): T = this.await.resultOrException match {
case None => throw new java.util.concurrent.TimeoutException("Future timed out!")
case s: Some[T] => s.get
}
def apply(): T = this.await.resultOrException.get
/**
* Java API for apply()

View file

@ -334,6 +334,11 @@ class FutureSpec extends JUnitSuite {
assert(f2.resultOrException === None)
latch.open
assert(f2() === 10)
val f3 = Future({ Thread.sleep(100); 5}, 10)
intercept[FutureTimeoutException] {
f3()
}
}
@Test def lesslessIsMore {