Tweaking the encoding of map keys so that there is no possibility of stomping on the key used to hold the map keyset

This commit is contained in:
ticktock 2010-11-07 19:21:06 -05:00
commit f252efe734
3 changed files with 60 additions and 10 deletions

View file

@ -76,6 +76,14 @@ class ActorKilledException private[akka](message: String) extends AkkaException(
class ActorInitializationException private[akka](message: String) extends AkkaException(message)
class ActorTimeoutException private[akka](message: String) extends AkkaException(message)
/**
* This message is thrown by default when an Actors behavior doesn't match a message
*/
case class UnhandledMessageException(msg: Any, ref: ActorRef) extends Exception {
override def getMessage() = "Actor %s does not handle [%s]".format(ref,msg)
override def fillInStackTrace() = this //Don't waste cycles generating stack trace
}
/**
* Actor factory module with factory methods for creating various kinds of Actors.
*
@ -387,6 +395,16 @@ trait Actor extends Logging {
*/
def postRestart(reason: Throwable) {}
/**
* User overridable callback.
* <p/>
* Is called when a message isn't handled by the current behavior of the actor
* by default it throws an UnhandledMessageException
*/
def unhandled(msg: Any){
throw new UnhandledMessageException(msg,self)
}
/**
* Is the actor able to handle the message passed in as arguments?
*/
@ -407,8 +425,9 @@ trait Actor extends Logging {
// ==== INTERNAL IMPLEMENTATION DETAILS ====
// =========================================
private[akka] def apply(msg: Any) = processingBehavior(msg)
private[akka] def apply(msg: Any) = fullBehavior(msg)
/*Processingbehavior and fullBehavior are duplicates so make sure changes are done to both */
private lazy val processingBehavior: Receive = {
lazy val defaultBehavior = receive
val actorBehavior: Receive = {
@ -426,6 +445,25 @@ trait Actor extends Logging {
}
actorBehavior
}
private lazy val fullBehavior: Receive = {
lazy val defaultBehavior = receive
val actorBehavior: Receive = {
case HotSwap(code) => become(code)
case RevertHotSwap => unbecome
case Exit(dead, reason) => self.handleTrapExit(dead, reason)
case Link(child) => self.link(child)
case Unlink(child) => self.unlink(child)
case UnlinkAndStop(child) => self.unlink(child); child.stop
case Restart(reason) => throw reason
case msg if !self.hotswap.isEmpty &&
self.hotswap.head.isDefinedAt(msg) => self.hotswap.head.apply(msg)
case msg if self.hotswap.isEmpty &&
defaultBehavior.isDefinedAt(msg) => defaultBehavior.apply(msg)
case unknown => unhandled(unknown) //This is the only line that differs from processingbehavior
}
actorBehavior
}
}
private[actor] class AnyOptionAsTypedOption(anyOption: Option[Any]) {

View file

@ -1,5 +1,6 @@
project.name=Akka SBT Plugin
project.organization=akka
# need full domain name for publishing to scala-tools
project.organization=se.scalablesolutions.akka
# mirrors akka version
project.version=1.0-SNAPSHOT
sbt.version=0.7.4

View file

@ -1,13 +1,17 @@
import sbt._
object AkkaRepositories {
val AkkaRepo = MavenRepository("Akka Repository", "http://scalablesolutions.se/akka/repository")
val CodehausRepo = MavenRepository("Codehaus Repo", "http://repository.codehaus.org")
val GuiceyFruitRepo = MavenRepository("GuiceyFruit Repo", "http://guiceyfruit.googlecode.com/svn/repo/releases/")
val JBossRepo = MavenRepository("JBoss Repo", "http://repository.jboss.org/nexus/content/groups/public/")
val JavaNetRepo = MavenRepository("java.net Repo", "http://download.java.net/maven/2")
val SonatypeSnapshotRepo = MavenRepository("Sonatype OSS Repo", "http://oss.sonatype.org/content/repositories/releases")
val SunJDMKRepo = MavenRepository("Sun JDMK Repo", "http://wp5.e-taxonomy.eu/cdmlib/mavenrepo")
val AkkaRepo = MavenRepository("Akka Repository", "http://scalablesolutions.se/akka/repository")
val CasbahRepo = MavenRepository("Casbah Repo", "http://repo.bumnetworks.com/releases")
val CasbahSnapshotRepo = MavenRepository("Casbah Snapshots", "http://repo.bumnetworks.com/snapshots")
val ClojarsRepo = MavenRepository("Clojars Repo", "http://clojars.org/repo")
val CodehausRepo = MavenRepository("Codehaus Repo", "http://repository.codehaus.org")
val GuiceyFruitRepo = MavenRepository("GuiceyFruit Repo", "http://guiceyfruit.googlecode.com/svn/repo/releases/")
val JBossRepo = MavenRepository("JBoss Repo", "http://repository.jboss.org/nexus/content/groups/public/")
val JavaNetRepo = MavenRepository("java.net Repo", "http://download.java.net/maven/2")
val SonatypeSnapshotRepo = MavenRepository("Sonatype OSS Repo", "http://oss.sonatype.org/content/repositories/releases")
val SunJDMKRepo = MavenRepository("Sun JDMK Repo", "http://wp5.e-taxonomy.eu/cdmlib/mavenrepo")
val ZookeeperRepo = MavenRepository("Zookeeper Repo", "http://lilycms.org/maven/maven2/deploy/")
}
trait AkkaBaseProject extends BasicScalaProject {
@ -21,16 +25,20 @@ trait AkkaBaseProject extends BasicScalaProject {
val aspectwerkzModuleConfig = ModuleConfiguration("org.codehaus.aspectwerkz", AkkaRepo)
val cassandraModuleConfig = ModuleConfiguration("org.apache.cassandra", AkkaRepo)
val eaioModuleConfig = ModuleConfiguration("com.eaio", AkkaRepo)
val facebookModuleConfig = ModuleConfiguration("com.facebook", AkkaRepo)
val h2lzfModuleConfig = ModuleConfiguration("voldemort.store.compress", AkkaRepo)
val hbaseModuleConfig = ModuleConfiguration("org.apache.hbase", AkkaRepo)
val jsr166xModuleConfig = ModuleConfiguration("jsr166x", AkkaRepo)
val netLagModuleConfig = ModuleConfiguration("net.lag", AkkaRepo)
val redisModuleConfig = ModuleConfiguration("com.redis", AkkaRepo)
val sbinaryModuleConfig = ModuleConfiguration("sbinary", AkkaRepo)
val sjsonModuleConfig = ModuleConfiguration("sjson.json", AkkaRepo)
val voldemortModuleConfig = ModuleConfiguration("voldemort.store.compress", AkkaRepo)
val triforkModuleConfig = ModuleConfiguration("com.trifork", AkkaRepo)
val vscaladocModuleConfig = ModuleConfiguration("org.scala-tools", "vscaladoc", "1.1-md-3", AkkaRepo)
val atmosphereModuleConfig = ModuleConfiguration("org.atmosphere", SonatypeSnapshotRepo)
val casbahModuleConfig = ModuleConfiguration("com.novus", CasbahRepo)
val grizzlyModuleConfig = ModuleConfiguration("com.sun.grizzly", JavaNetRepo)
val guiceyFruitModuleConfig = ModuleConfiguration("org.guiceyfruit", GuiceyFruitRepo)
val jbossModuleConfig = ModuleConfiguration("org.jboss", JBossRepo)
@ -42,6 +50,9 @@ trait AkkaBaseProject extends BasicScalaProject {
val jgroupsModuleConfig = ModuleConfiguration("jgroups", JBossRepo)
val multiverseModuleConfig = ModuleConfiguration("org.multiverse", CodehausRepo)
val nettyModuleConfig = ModuleConfiguration("org.jboss.netty", JBossRepo)
val timeModuleConfig = ModuleConfiguration("org.scala-tools", "time", CasbahSnapshotRepo)
val voldemortModuleConfig = ModuleConfiguration("voldemort", ClojarsRepo)
val zookeeperModuleConfig = ModuleConfiguration("org.apache.hadoop.zookeeper", ZookeeperRepo)
}
trait AkkaProject extends AkkaBaseProject {