summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorphaller <hallerp@gmail.com>2012-04-14 20:37:14 +0200
committerphaller <hallerp@gmail.com>2012-04-14 20:37:14 +0200
commit23aa1a8d7b08b767f90657baf9bc13a355682671 (patch)
tree7243f629540c7c34b89d5de5fc12d788133f00f7 /src
parent1246f69185d958f12ebbff047fc3a72766cfd384 (diff)
downloadscala-23aa1a8d7b08b767f90657baf9bc13a355682671.tar.gz
scala-23aa1a8d7b08b767f90657baf9bc13a355682671.tar.bz2
scala-23aa1a8d7b08b767f90657baf9bc13a355682671.zip
Fix issues with exception handling in futures. Review by @heathermiller
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/concurrent/Future.scala2
-rw-r--r--src/library/scala/concurrent/impl/ExecutionContextImpl.scala6
-rw-r--r--src/library/scala/concurrent/impl/Future.scala8
3 files changed, 12 insertions, 4 deletions
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala
index 89b04e6248..04f56950f1 100644
--- a/src/library/scala/concurrent/Future.scala
+++ b/src/library/scala/concurrent/Future.scala
@@ -312,7 +312,7 @@ trait Future[+T] extends Awaitable[T] {
if (pf.isDefinedAt(v)) p success pf(v)
else p failure new NoSuchElementException("Future.collect partial function is not defined at: " + v)
} catch {
- case t: Throwable => p complete resolver(t)
+ case NonFatal(t) => p complete resolver(t)
}
}
diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
index c308a59297..2b929d91ab 100644
--- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
+++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala
@@ -93,8 +93,12 @@ private[scala] class ExecutionContextImpl(es: AnyRef) extends ExecutionContext w
}
def reportFailure(t: Throwable) = t match {
+ /*TODO: clarify that resolver should wrap Errors, in which case we do not want
+ Error to be re-thrown here */
case e: Error => throw e // rethrow serious errors
- case t => t.printStackTrace()
+ case t =>
+ //println(t.toString)
+ t.printStackTrace()
}
}
diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala
index 1cc9e95463..9743c37403 100644
--- a/src/library/scala/concurrent/impl/Future.scala
+++ b/src/library/scala/concurrent/impl/Future.scala
@@ -71,14 +71,18 @@ object Future {
def apply[T](body: =>T)(implicit executor: ExecutionContext): Future[T] = {
val promise = new Promise.DefaultPromise[T]()
+
+ //TODO: shouldn't the following be:
+ //dispatchFuture(executor, () => { promise complete Right(body) })
+
executor.execute(new Runnable {
def run = {
promise complete {
try {
Right(body)
} catch {
- case NonFatal(e) =>
- executor.reportFailure(e)
+ case e =>
+ //executor.reportFailure(e)
scala.concurrent.resolver(e)
}
}