From 6c4d41fbcc59ab2080036d7f0ed2f82d4911977d Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Wed, 15 Sep 2010 09:10:31 +0000 Subject: Shield interrupts against exceptions in user code --- src/compiler/scala/tools/nsc/util/InterruptReq.scala | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/compiler/scala/tools/nsc/util/InterruptReq.scala b/src/compiler/scala/tools/nsc/util/InterruptReq.scala index aa7804acbe..e7c05beb65 100644 --- a/src/compiler/scala/tools/nsc/util/InterruptReq.scala +++ b/src/compiler/scala/tools/nsc/util/InterruptReq.scala @@ -12,17 +12,24 @@ abstract class InterruptReq { protected val todo: () => R /** The result provided */ - private var result: Option[R] = None + private var result: Option[Either[R, Throwable]] = None /** To be called from interrupted server to execute demanded task */ def execute(): Unit = synchronized { - result = Some(todo()) + try { + result = Some(Left(todo())) + } catch { + case t => result = Some(Right(t)) + } notify() } /** To be called from interrupting client to get result fo interrupt */ def getResult(): R = synchronized { while (result.isEmpty) wait() - result.get + result.get match { + case Left(res) => res + case Right(t) => throw t + } } } -- cgit v1.2.3