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 {