From 83e17aa8eade14aee691863eb3a5e1cd224bff7b Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Wed, 19 Oct 2011 17:48:27 +0200 Subject: [PATCH] Removing the 'def config', removing the null check for every message being processed and adding some TODOs --- akka-actor/src/main/scala/akka/actor/Actor.scala | 16 ++++++---------- .../scala/akka/dispatch/AbstractDispatcher.scala | 4 +++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/akka-actor/src/main/scala/akka/actor/Actor.scala b/akka-actor/src/main/scala/akka/actor/Actor.scala index 5d72c77d60..c61ec6f0b9 100644 --- a/akka-actor/src/main/scala/akka/actor/Actor.scala +++ b/akka-actor/src/main/scala/akka/actor/Actor.scala @@ -212,12 +212,10 @@ trait Actor { implicit def app = context.app - private def config = context.app.AkkaConfig - /** * The default timeout, based on the config setting 'akka.actor.timeout' */ - implicit def defaultTimeout = config.ActorTimeout + implicit def defaultTimeout = app.AkkaConfig.ActorTimeout /** * Wrap a Receive partial function in a logging enclosure, which sends a @@ -233,7 +231,7 @@ trait Actor { * This method does NOT modify the given Receive unless * akka.actor.debug.receive is set within akka.conf. */ - def loggable(self: AnyRef)(r: Receive): Receive = if (config.AddLoggingReceive) LoggingReceive(self, r) else r + def loggable(self: AnyRef)(r: Receive): Receive = if (app.AkkaConfig.AddLoggingReceive) LoggingReceive(self, r) else r //TODO FIXME Shouldn't this be in a Loggable-trait? /** * Some[ActorRef] representation of the 'self' ActorRef reference. @@ -241,7 +239,7 @@ trait Actor { * Mainly for internal use, functions as the implicit sender references when invoking * the 'forward' function. */ - def someSelf: Some[ActorRef with ScalaActorRef] = Some(context.self) + def someSelf: Some[ActorRef with ScalaActorRef] = Some(context.self) //TODO FIXME we might not need this when we switch to sender-in-scope-always /* * Option[ActorRef] representation of the 'self' ActorRef reference. @@ -249,7 +247,7 @@ trait Actor { * Mainly for internal use, functions as the implicit sender references when invoking * one of the message send functions ('!' and '?'). */ - def optionSelf: Option[ActorRef with ScalaActorRef] = someSelf + def optionSelf: Option[ActorRef with ScalaActorRef] = someSelf //TODO FIXME we might not need this when we switch to sender-in-scope-always /** * The 'self' field holds the ActorRef for this actor. @@ -272,7 +270,7 @@ trait Actor { */ def channel: UntypedChannel = context.channel - // just for current compatibility + // TODO FIXME REMOVE ME just for current compatibility implicit def forwardable: ForwardableChannel = ForwardableChannel(channel) /** @@ -387,11 +385,9 @@ trait Actor { // ========================================= private[akka] final def apply(msg: Any) = { - if (msg.isInstanceOf[AnyRef] && (msg.asInstanceOf[AnyRef] eq null)) - throw new InvalidMessageException("Message from [" + channel + "] to [" + self + "] is null") def autoReceiveMessage(msg: AutoReceivedMessage) { - if (config.DebugAutoReceive) app.eventHandler.debug(this, "received AutoReceiveMessage " + msg) + if (app.AkkaConfig.DebugAutoReceive) app.eventHandler.debug(this, "received AutoReceiveMessage " + msg) msg match { case HotSwap(code, discardOld) ⇒ become(code(self), discardOld) diff --git a/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala index d7bdb68229..7bcf72667a 100644 --- a/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala @@ -17,7 +17,9 @@ import scala.annotation.tailrec /** * @author Jonas Bonér */ -final case class Envelope(val message: Any, val channel: UntypedChannel) +final case class Envelope(val message: Any, val channel: UntypedChannel) { + if (message.isInstanceOf[AnyRef] && (message.asInstanceOf[AnyRef] eq null)) throw new InvalidMessageException("Message is null") +} object SystemMessage { @tailrec