From f74151a67faea38801228f201aa562a394fecbb2 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 22 Mar 2011 22:20:32 +0100 Subject: [PATCH] Switched to FutureTimeoutException for Future.apply/Future.get --- akka-actor/src/main/scala/akka/dispatch/Future.scala | 5 +---- akka-actor/src/test/scala/akka/dispatch/FutureSpec.scala | 5 +++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index 370bad6d1c..6ca346dbdf 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -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() diff --git a/akka-actor/src/test/scala/akka/dispatch/FutureSpec.scala b/akka-actor/src/test/scala/akka/dispatch/FutureSpec.scala index 2cdd9b340d..ec46140859 100644 --- a/akka-actor/src/test/scala/akka/dispatch/FutureSpec.scala +++ b/akka-actor/src/test/scala/akka/dispatch/FutureSpec.scala @@ -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 {