diff options
author | Aleksandar Prokopec <aleksandar.prokopec@gmail.com> | 2011-12-07 15:42:16 +0100 |
---|---|---|
committer | Aleksandar Prokopec <aleksandar.prokopec@gmail.com> | 2011-12-07 15:42:16 +0100 |
commit | 4b62e8059c1f0f8cb4624291b0aa64e6e460948e (patch) | |
tree | a61b887c8d96e11f2d9a475db7af25f48e4ced81 | |
parent | 35b8d97cc339fe8b6499bf2d8897f9dd74ad071c (diff) | |
download | scala-4b62e8059c1f0f8cb4624291b0aa64e6e460948e.tar.gz scala-4b62e8059c1f0f8cb4624291b0aa64e6e460948e.tar.bz2 scala-4b62e8059c1f0f8cb4624291b0aa64e6e460948e.zip |
Fixing match errors in the on* callback methods in future.
-rw-r--r-- | src/library/scala/concurrent/Future.scala | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 0680e87736..eff155f5e9 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -72,13 +72,12 @@ self => * If the future has already been completed with a value, * this will either be applied immediately or be scheduled asynchronously. * - * Will not be called in case of a timeout. - * - * Will not be called in case of an exception. + * Will not be called in case of an exception (this includes the FutureTimeoutException). * * $multipleCallbacks */ def onSuccess[U](func: T => U): this.type = onComplete { + case Left(t) => // do nothing case Right(v) => func(v) } @@ -90,14 +89,15 @@ self => * If the future has already been completed with a failure, * this will either be applied immediately or be scheduled asynchronously. * - * Will not be called in case of a timeout. + * Will not be called in case that the future is completed with a value. * - * Will not be called in case of an exception. + * Will be called if the future is completed with a FutureTimeoutException. * * $multipleCallbacks */ def onFailure[U](func: Throwable => U): this.type = onComplete { case Left(t) if isFutureThrowable(t) => func(t) + case Right(v) => // do nothing } /** When this future times out, apply the provided function. @@ -107,8 +107,9 @@ self => * * $multipleCallbacks */ - def onTimeout[U](body: =>U): this.type = onComplete { - case Left(te: FutureTimeoutException) => body + def onTimeout[U](body: FutureTimeoutException => U): this.type = onComplete { + case Left(te: FutureTimeoutException) => body(te) + case Right(v) => // do nothing } /** When this future is completed, either through an exception, a timeout, or a value, |