From dcbffd4dc50c7e2540fd4770492b86108d3254fc Mon Sep 17 00:00:00 2001 From: Philipp Haller Date: Thu, 22 Apr 2010 08:04:12 +0000 Subject: Reactor.exceptionHandler is defined on Throwabl... Reactor.exceptionHandler is defined on Throwable instead of Exception. Fixes potential problem with visibility of changes to a field. Review by plocinic. --- test/files/jvm/actor-exceptions.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'test/files/jvm/actor-exceptions.scala') diff --git a/test/files/jvm/actor-exceptions.scala b/test/files/jvm/actor-exceptions.scala index 384226d777..75dc1e4cd5 100644 --- a/test/files/jvm/actor-exceptions.scala +++ b/test/files/jvm/actor-exceptions.scala @@ -19,6 +19,7 @@ object Master extends Actor { for (i <- 0 until 10) Slave ! A react { case Exit(from, reason) => + println("OK") } } catch { case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => @@ -29,8 +30,9 @@ object Master extends Actor { object Slave extends Actor { override def toString = "Slave" - override def exceptionHandler: PartialFunction[Exception, Unit] = { + override def exceptionHandler: PartialFunction[Throwable, Unit] = { case MyException(text) => + case other if !other.isInstanceOf[scala.util.control.ControlThrowable] => super.exceptionHandler(other) } def act() { try { @@ -41,12 +43,14 @@ object Slave extends Actor { cnt += 1 if (cnt % 2 != 0) throw MyException("problem") if (cnt == 10) { - throw new MyOtherException("unhandled") + throw MyOtherException("unhandled") } } } } catch { - case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] => + case e: Throwable if !e.isInstanceOf[scala.util.control.ControlThrowable] && + !e.isInstanceOf[MyException] && + !e.isInstanceOf[MyOtherException] => e.printStackTrace() } } -- cgit v1.2.3