fix warnings in actor and testkit

This commit is contained in:
Roland Kuhn 2015-01-30 11:33:33 +01:00
parent 7083eb46c8
commit 613f63b526
8 changed files with 34 additions and 33 deletions

View file

@ -326,7 +326,7 @@ private[akka] class LocalActorRef private[akka] (
* If this method returns true, it will never return false again, but if it
* returns false, you cannot be sure if it's alive still (race condition)
*/
@deprecated("Use context.watch(actor) and receive Terminated(actor)", "2.2") override def isTerminated: Boolean = actorCell.isTerminated
override def isTerminated: Boolean = actorCell.isTerminated
/**
* Starts the actor after initialization.

View file

@ -294,20 +294,20 @@ abstract class SupervisorStrategy {
def handleFailure(context: ActorContext, child: ActorRef, cause: Throwable, stats: ChildRestartStats, children: Iterable[ChildRestartStats]): Boolean = {
val directive = decider.applyOrElse(cause, escalateDefault)
directive match {
case d @ Resume
logFailure(context, child, cause, d)
case Resume
logFailure(context, child, cause, directive)
resumeChild(child, cause)
true
case d @ Restart
logFailure(context, child, cause, d)
case Restart
logFailure(context, child, cause, directive)
processFailure(context, true, child, cause, stats, children)
true
case d @ Stop
logFailure(context, child, cause, d)
case Stop
logFailure(context, child, cause, directive)
processFailure(context, false, child, cause, stats, children)
true
case d @ Escalate
logFailure(context, child, cause, d)
case Escalate
logFailure(context, child, cause, directive)
false
}
}

View file

@ -293,7 +293,7 @@ object TypedActor extends ExtensionId[TypedActorExtension] with ExtensionIdProvi
}
}
protected def withContext[T](unitOfWork: T): T = {
protected def withContext[U](unitOfWork: U): U = {
TypedActor.selfReference set proxyVar.get
TypedActor.currentContext set context
try unitOfWork finally {

View file

@ -300,7 +300,7 @@ class CircuitBreaker(scheduler: Scheduler, maxFailures: Int, callTimeout: Finite
*/
def callThrough[T](body: Future[T]): Future[T] = {
def materialize[T](value: Future[T]): Future[T] = try value catch { case NonFatal(t) Future.failed(t) }
def materialize[U](value: Future[U]): Future[U] = try value catch { case NonFatal(t) Future.failed(t) }
if (callTimeout == Duration.Zero) {
materialize(body)

View file

@ -46,18 +46,15 @@ trait GracefulStopSupport {
* }}}
*/
def gracefulStop(target: ActorRef, timeout: FiniteDuration, stopMessage: Any = PoisonPill): Future[Boolean] = {
if (target.isTerminated) Future successful true
else {
val internalTarget = target.asInstanceOf[InternalActorRef]
val ref = PromiseActorRef(internalTarget.provider, Timeout(timeout), target, stopMessage.getClass.getName)
internalTarget.sendSystemMessage(Watch(internalTarget, ref))
target.tell(stopMessage, Actor.noSender)
ref.result.future.transform(
{
case Terminated(t) if t.path == target.path true
case _ { internalTarget.sendSystemMessage(Unwatch(target, ref)); false }
},
t { internalTarget.sendSystemMessage(Unwatch(target, ref)); t })(ref.internalCallingThreadExecutionContext)
}
val internalTarget = target.asInstanceOf[InternalActorRef]
val ref = PromiseActorRef(internalTarget.provider, Timeout(timeout), target, stopMessage.getClass.getName)
internalTarget.sendSystemMessage(Watch(internalTarget, ref))
target.tell(stopMessage, Actor.noSender)
ref.result.future.transform(
{
case Terminated(t) if t.path == target.path true
case _ { internalTarget.sendSystemMessage(Unwatch(target, ref)); false }
},
t { internalTarget.sendSystemMessage(Unwatch(target, ref)); t })(ref.internalCallingThreadExecutionContext)
}
}

View file

@ -39,12 +39,11 @@ class AkkaSpecSpec extends WordSpec with Matchers {
"akka.actor.debug.lifecycle" -> true, "akka.actor.debug.event-stream" -> true,
"akka.loglevel" -> "DEBUG", "akka.stdout-loglevel" -> "DEBUG")
val system = ActorSystem("AkkaSpec1", ConfigFactory.parseMap(conf.asJava).withFallback(AkkaSpec.testConf))
val spec = new AkkaSpec(system) {
val ref = Seq(testActor, system.actorOf(Props.empty, "name"))
}
spec.ref foreach (_.isTerminated should not be true)
var refs = Seq.empty[ActorRef]
val spec = new AkkaSpec(system) { refs = Seq(testActor, system.actorOf(Props.empty, "name")) }
refs foreach (_.isTerminated should not be true)
TestKit.shutdownActorSystem(system)
spec.awaitCond(spec.ref forall (_.isTerminated), 2 seconds)
spec.awaitCond(refs forall (_.isTerminated), 2 seconds)
}
"stop correctly when sending PoisonPill to rootGuardian" in {

View file

@ -227,12 +227,13 @@ class TestActorRefSpec extends AkkaSpec("disp1.type=Dispatcher") with BeforeAndA
"A TestActorRef" must {
"allow access to internals" in {
val ref = TestActorRef(new TActor {
class TA extends TActor {
var s: String = _
def receiveT = {
case x: String s = x
}
})
}
val ref = TestActorRef(new TA)
ref ! "hallo"
val actor = ref.underlyingActor
actor.s should be("hallo")

View file

@ -287,11 +287,15 @@ object AkkaBuild extends Build {
pomIncludeRepository := (_ => false) // do not leak internal repositories during staging
)
private def deprecation: Boolean = System.getProperty("akka.deprecation", "false").toBoolean
lazy val defaultSettings = baseSettings ++ resolverSettings ++ TestExtras.Filter.settings ++
Protobuf.settings ++ Seq(
// compile options
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.6", "-deprecation", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.6", "-target", "1.6", "-Xlint:unchecked", "-Xlint:deprecation"),
scalacOptions in Compile ++= Seq("-encoding", "UTF-8", "-target:jvm-1.6", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
scalacOptions in Compile ++= (if (deprecation) Seq("-deprecation") else Nil),
javacOptions in compile ++= Seq("-encoding", "UTF-8", "-source", "1.6", "-target", "1.6", "-Xlint:unchecked", "-XDignore.symbol.file"),
javacOptions in compile ++= (if (deprecation) Seq("-Xlint:deprecation") else Nil),
javacOptions in doc ++= Seq("-encoding", "UTF-8", "-source", "1.6"),
incOptions := incOptions.value.withNameHashing(true),