Skip to content

Commit

Permalink
Fixes #2302 - removing potential race in ActorSystemSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
viktorklang committed Jul 6, 2012
1 parent b6a5796 commit 948287f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala
Expand Up @@ -165,20 +165,22 @@ class ActorSystemSpec extends AkkaSpec("""akka.extensions = ["akka.actor.TestExt
system.scheduler.scheduleOnce(200 millis) { system.shutdown() }
var failing = false
var created = Vector.empty[ActorRef]
while (!system.isTerminated && system.uptime < 5) {
while (!system.isTerminated) {
try {
val t = system.actorOf(Props[ActorSystemSpec.Terminater])
failing must not be true // because once failing => always failing (it’s due to shutdown)
created :+= t
} catch {
case _: IllegalStateException failing = true
}

if (!failing && system.uptime >= 5) {
println(created.last)
println(system.asInstanceOf[ExtendedActorSystem].printTree)
fail("System didn't terminate within 5 seconds")
}
}
if (system.uptime >= 5) {
println(created.last)
println(system.asInstanceOf[ExtendedActorSystem].printTree)
system.uptime must be < 5L
}

created filter (ref !ref.isTerminated && !ref.asInstanceOf[ActorRefWithCell].underlying.isInstanceOf[UnstartedCell]) must be(Seq())
}

Expand Down

0 comments on commit 948287f

Please sign in to comment.