Given the following on Scala 2.11.8:
import scala.concurrent.Future
import scala.concurrent.duration._
import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
scala> def fut = {
| Thread.sleep(5000)
| Future(42)
| }
fut: scala.concurrent.Future[Int]
Why does the following not throw a java.util.TimeoutException?
scala> Await.result( fut, FiniteDuration(1, SECONDS) )
res1: Int = 42
As I understand, Await#result will throw if the time-out, i.e. its second argument, completes before the completion of the Future.
If that's true, then why does 42 return in the above example instead of an exception?