make sure that InterruptExceptions are not swallowed, see #2963

also remove an old work-around in CallingThreadDispatcherModelSpec and
describe the rules for interrupting in the testing docs
This commit is contained in:
Roland 2013-01-27 12:56:35 +01:00
parent afb5740d74
commit b881963907
5 changed files with 75 additions and 51 deletions

View file

@ -13,7 +13,7 @@ import akka.pattern.pipe
import scala.concurrent.Future
import scala.util.control.NonFatal
import akka.actor.SystemGuardian.{ TerminationHookDone, TerminationHook, RegisterTerminationHook }
import scala.throws
import scala.util.control.Exception.Catcher
object RemoteActorRefProvider {
private case class Internals(transport: RemoteTransport, serialization: Serialization, remoteDaemon: InternalActorRef)
@ -339,21 +339,18 @@ private[akka] class RemoteActorRef private[akka] (
def isTerminated: Boolean = false
def sendSystemMessage(message: SystemMessage): Unit =
try remote.send(message, None, this)
catch {
case e @ (_: InterruptedException | NonFatal(_))
remote.system.eventStream.publish(Error(e, path.toString, classOf[RemoteActorRef], "swallowing exception during message send"))
provider.deadLetters ! message
}
private def handleException: Catcher[Unit] = {
case e: InterruptedException
remote.system.eventStream.publish(Error(e, path.toString, getClass, "interrupted during message send"))
Thread.currentThread.interrupt()
case NonFatal(e)
remote.system.eventStream.publish(Error(e, path.toString, getClass, "swallowing exception during message send"))
}
def sendSystemMessage(message: SystemMessage): Unit = try remote.send(message, None, this) catch handleException
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit =
try remote.send(message, Option(sender), this)
catch {
case e @ (_: InterruptedException | NonFatal(_))
remote.system.eventStream.publish(Error(e, path.toString, classOf[RemoteActorRef], "swallowing exception during message send"))
provider.deadLetters ! message
}
try remote.send(message, Option(sender), this) catch handleException
def start(): Unit = if (props.isDefined && deploy.isDefined) provider.useActorOnNode(path, props.get, deploy.get, getParent)