From 916c2d4d11f4701dbf0cf11f94b5dd5f20180cdf Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 22 May 2012 12:14:33 +0200 Subject: [PATCH] Switching to checking InstantiationException for both create and recreate --- akka-actor/src/main/scala/akka/actor/Actor.scala | 2 +- akka-actor/src/main/scala/akka/actor/ActorCell.scala | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/akka-actor/src/main/scala/akka/actor/Actor.scala b/akka-actor/src/main/scala/akka/actor/Actor.scala index b611d96842..3d93e52a54 100644 --- a/akka-actor/src/main/scala/akka/actor/Actor.scala +++ b/akka-actor/src/main/scala/akka/actor/Actor.scala @@ -118,7 +118,7 @@ class ActorKilledException private[akka] (message: String, cause: Throwable) * An InvalidActorNameException is thrown when you try to convert something, usually a String, to an Actor name * which doesn't validate. */ -case class InvalidActorNameException(message: String) extends AkkaException(message) +class InvalidActorNameException(message: String) extends AkkaException(message) /** * An ActorInitializationException is thrown when the the initialization logic for an Actor fails. diff --git a/akka-actor/src/main/scala/akka/actor/ActorCell.scala b/akka-actor/src/main/scala/akka/actor/ActorCell.scala index 3380d51de0..3b2c743a6b 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorCell.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorCell.scala @@ -498,7 +498,7 @@ private[akka] class ActorCell( import ActorCell.behaviorStackPlaceHolder behaviorStack = behaviorStackPlaceHolder - val instance = props.creator() + val instance = props.creator.apply() if (instance eq null) throw new ActorInitializationException(self, "Actor instance passed to actorOf can't be 'null'") @@ -532,8 +532,7 @@ private[akka] class ActorCell( a non-static inner class (in which case make it a static inner class or use Props(new ...) or Props( new UntypedActorFactory ... ) or is missing an appropriate, reachable no-args constructor. """, i.getCause) - case NonFatal(e) ⇒ - throw new ActorInitializationException(self, "exception during creation", e) + case NonFatal(e) ⇒ throw new ActorInitializationException(self, "exception during creation", e) } } @@ -557,7 +556,10 @@ private[akka] class ActorCell( doRecreate(cause, failedActor) } } catch { - case NonFatal(e) ⇒ throw new ActorInitializationException(self, "exception during creation", e) + case NonFatal(e) ⇒ throw new ActorInitializationException(self, "exception during creation", e match { + case i: InstantiationException => i.getCause + case other => other + }) } }