diff --git a/akka-actor/src/main/scala/akka/dispatch/Mailbox.scala b/akka-actor/src/main/scala/akka/dispatch/Mailbox.scala index 1691713ea3..86b286e916 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Mailbox.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Mailbox.scala @@ -389,8 +389,8 @@ class CustomMailboxType(mailboxFQN: String) extends MailboxType { override def create(receiver: ActorContext): Mailbox = { val constructorSignature = Array[Class[_]](classOf[ActorContext]) - ReflectiveAccess.createInstance[AnyRef](mailboxFQN, constructorSignature, Array[AnyRef](receiver)) match { - case Right(instance) ⇒ instance.asInstanceOf[Mailbox] + ReflectiveAccess.createInstance[Mailbox](mailboxFQN, constructorSignature, Array[AnyRef](receiver)) match { + case Right(instance) ⇒ instance case Left(exception) ⇒ throw new IllegalArgumentException("Cannot instantiate mailbox [%s] due to: %s". format(mailboxFQN, exception.toString)) diff --git a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala index 0e738541ae..70b6fa5a03 100644 --- a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala +++ b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala @@ -100,7 +100,8 @@ object ReflectiveAccess { * Unwraps `InvocationTargetException` if its getTargetException is an `Exception`. * Other `Throwable`, such as `Error` is thrown. */ - private def withErrorHandling[T](body: ⇒ Either[Exception, T]): Either[Exception, T] = { + @inline + private final def withErrorHandling[T](body: ⇒ Either[Exception, T]): Either[Exception, T] = { try { body } catch {