diff --git a/akka-core/src/main/scala/actor/ActorRef.scala b/akka-core/src/main/scala/actor/ActorRef.scala index 5a1653e195..c7473f46e3 100644 --- a/akka-core/src/main/scala/actor/ActorRef.scala +++ b/akka-core/src/main/scala/actor/ActorRef.scala @@ -975,7 +975,7 @@ sealed class LocalActorRef private[akka]( } /** - * Callback for the dispatcher. E.g. single entry point to the user code and all protected[this] methods. + * Callback for the dispatcher. This is the ingle entry point to the user Actor implementation. */ protected[akka] def invoke(messageHandle: MessageInvocation): Unit = actor.synchronized { if (isShutdown) { @@ -1180,6 +1180,7 @@ sealed class LocalActorRef private[akka]( Actor.log.debug("[%s] has started", toString) ActorRegistry.register(this) if (id == "N/A") id = actorClass.getName // if no name set, then use default name (class name) + clearTransactionSet // clear transaction set that might have been created if atomic block has been used within the Actor constructor body } private def serializeMessage(message: AnyRef): AnyRef = if (Actor.SERIALIZE_MESSAGES) { diff --git a/akka-core/src/test/scala/StmSpec.scala b/akka-core/src/test/scala/StmSpec.scala index 10e5a95d1b..28ec49a338 100644 --- a/akka-core/src/test/scala/StmSpec.scala +++ b/akka-core/src/test/scala/StmSpec.scala @@ -81,35 +81,39 @@ class StmSpec extends } total should equal(0) } + } + describe("Transaction.Global") { it("should be able to initialize with atomic {..} block inside actor constructor") { - import StmSpecVectorTestActor._ + import GlobalTransactionVectorTestActor._ try { - val actor = actorOf[StmSpecVectorTestActor].start + val actor = actorOf[GlobalTransactionVectorTestActor].start actor !! Add(5) val size1: Int = (actor !! Size).getOrElse(fail("Could not get Vector::size")) size1 should equal(2) actor !! Add(2) val size2: Int = (actor !! Size).getOrElse(fail("Could not get Vector::size")) - size2 should equal(2) + size2 should equal(3) } catch { - case e => fail(e.toString) + case e => + e.printStackTrace + fail(e.toString) } } } } -object StmSpecVectorTestActor { +object GlobalTransactionVectorTestActor { case class Add(value: Int) case object Size case object Success } -class StmSpecVectorTestActor extends Actor { - import StmSpecVectorTestActor._ +class GlobalTransactionVectorTestActor extends Actor { + import GlobalTransactionVectorTestActor._ import se.scalablesolutions.akka.stm.Transaction.Global private var vector: TransactionalVector[Int] = Global.atomic { TransactionalVector(1) } - + def receive = { case Add(value) => Global.atomic { vector + value} diff --git a/config/akka-reference.conf b/config/akka-reference.conf index 5311712ec4..72ef6bef3e 100644 --- a/config/akka-reference.conf +++ b/config/akka-reference.conf @@ -8,7 +8,7 @@ filename = "./logs/akka.log" roll = "daily" # Options: never, hourly, daily, sunday/monday/... - level = "debug" # Options: fatal, critical, error, warning, info, debug, trace + level = "info" # Options: fatal, critical, error, warning, info, debug, trace console = on # syslog_host = "" # syslog_server_name = ""