Merge pull request #22138 from VEINHORN/master

Remove unnecessary new keywords
This commit is contained in:
Patrik Nordwall 2017-01-17 19:31:45 +01:00 committed by GitHub
commit 6c8a69109a
21 changed files with 34 additions and 34 deletions

View file

@ -434,11 +434,11 @@ object SupervisorHierarchySpec {
var hierarchy: ActorRef = _ var hierarchy: ActorRef = _
override def preRestart(cause: Throwable, msg: Option[Any]) { override def preRestart(cause: Throwable, msg: Option[Any]) {
throw new ActorKilledException("I want to DIE") throw ActorKilledException("I want to DIE")
} }
override def postRestart(cause: Throwable) { override def postRestart(cause: Throwable) {
throw new ActorKilledException("I said I wanted to DIE, dammit!") throw ActorKilledException("I said I wanted to DIE, dammit!")
} }
override def postStop { override def postStop {

View file

@ -340,7 +340,7 @@ private[akka] object ActorCell {
final val emptyActorRefSet: Set[ActorRef] = immutable.HashSet.empty final val emptyActorRefSet: Set[ActorRef] = immutable.HashSet.empty
final val terminatedProps: Props = Props((throw new IllegalActorStateException("This Actor has been terminated")): Actor) final val terminatedProps: Props = Props((throw IllegalActorStateException("This Actor has been terminated")): Actor)
final val undefinedUid = 0 final val undefinedUid = 0
@ -510,7 +510,7 @@ private[akka] class ActorCell(
msg.message match { msg.message match {
case t: Terminated receivedTerminated(t) case t: Terminated receivedTerminated(t)
case AddressTerminated(address) addressTerminated(address) case AddressTerminated(address) addressTerminated(address)
case Kill throw new ActorKilledException("Kill") case Kill throw ActorKilledException("Kill")
case PoisonPill self.stop() case PoisonPill self.stop()
case sel: ActorSelectionMessage receiveSelection(sel) case sel: ActorSelectionMessage receiveSelection(sel)
case Identify(messageId) sender() ! ActorIdentity(messageId, Some(self)) case Identify(messageId) sender() ! ActorIdentity(messageId, Some(self))
@ -642,7 +642,7 @@ private[akka] class ActorCell(
if (actorInstance ne null) { if (actorInstance ne null) {
if (!Reflect.lookupAndSetField(actorInstance.getClass, actorInstance, "context", context) if (!Reflect.lookupAndSetField(actorInstance.getClass, actorInstance, "context", context)
|| !Reflect.lookupAndSetField(actorInstance.getClass, actorInstance, "self", self)) || !Reflect.lookupAndSetField(actorInstance.getClass, actorInstance, "self", self))
throw new IllegalActorStateException(actorInstance.getClass + " is not an Actor since it have not mixed in the 'Actor' trait") throw IllegalActorStateException(actorInstance.getClass + " is not an Actor since it have not mixed in the 'Actor' trait")
} }
// logging is not the main purpose, and if it fails theres nothing we can do // logging is not the main purpose, and if it fails theres nothing we can do

View file

@ -88,9 +88,9 @@ object ActorPath {
case ValidPathCode case ValidPathCode
// valid // valid
case EmptyPathCode case EmptyPathCode
throw new InvalidActorNameException(s"Actor path element must not be empty $fullPathMsg") throw InvalidActorNameException(s"Actor path element must not be empty $fullPathMsg")
case invalidAt case invalidAt
throw new InvalidActorNameException( throw InvalidActorNameException(
s"""Invalid actor path element [$element]$fullPathMsg, illegal character [${element(invalidAt)}] at position: $invalidAt. """ + s"""Invalid actor path element [$element]$fullPathMsg, illegal character [${element(invalidAt)}] at position: $invalidAt. """ +
"""Actor paths MUST: """ + """Actor paths MUST: """ +
"""not start with `$`, """ + """not start with `$`, """ +

View file

@ -534,7 +534,7 @@ private[akka] class EmptyLocalActorRef(
} }
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = message match { override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = message match {
case null throw new InvalidMessageException("Message is null") case null throw InvalidMessageException("Message is null")
case d: DeadLetter case d: DeadLetter
specialHandle(d.message, d.sender) // do NOT form endless loops, since deadLetters will resend! specialHandle(d.message, d.sender) // do NOT form endless loops, since deadLetters will resend!
case _ if !specialHandle(message, sender) case _ if !specialHandle(message, sender)
@ -579,7 +579,7 @@ private[akka] class DeadLetterActorRef(
_eventStream: EventStream) extends EmptyLocalActorRef(_provider, _path, _eventStream) { _eventStream: EventStream) extends EmptyLocalActorRef(_provider, _path, _eventStream) {
override def !(message: Any)(implicit sender: ActorRef = this): Unit = message match { override def !(message: Any)(implicit sender: ActorRef = this): Unit = message match {
case null throw new InvalidMessageException("Message is null") case null throw InvalidMessageException("Message is null")
case Identify(messageId) sender ! ActorIdentity(messageId, None) case Identify(messageId) sender ! ActorIdentity(messageId, None)
case d: DeadLetter if (!specialHandle(d.message, d.sender)) eventStream.publish(d) case d: DeadLetter if (!specialHandle(d.message, d.sender)) eventStream.publish(d)
case _ if (!specialHandle(message, sender)) case _ if (!specialHandle(message, sender))

View file

@ -541,7 +541,7 @@ private[akka] class LocalActorRefProvider private[akka] (
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit =
if (isWalking) if (isWalking)
message match { message match {
case null throw new InvalidMessageException("Message is null") case null throw InvalidMessageException("Message is null")
case _ log.error(s"$this received unexpected message [$message]") case _ log.error(s"$this received unexpected message [$message]")
} }

View file

@ -153,7 +153,7 @@ private[akka] class Deployer(val settings: ActorSystem.Settings, val dynamicAcce
def deploy(d: Deploy): Unit = { def deploy(d: Deploy): Unit = {
@tailrec def add(path: Array[String], d: Deploy, w: WildcardIndex[Deploy] = deployments.get): Unit = { @tailrec def add(path: Array[String], d: Deploy, w: WildcardIndex[Deploy] = deployments.get): Unit = {
for (i path.indices) path(i) match { for (i path.indices) path(i) match {
case "" throw new InvalidActorNameException(s"Actor name in deployment [${d.path}] must not be empty") case "" throw InvalidActorNameException(s"Actor name in deployment [${d.path}] must not be empty")
case el ActorPath.validatePathElement(el, fullPath = d.path) case el ActorPath.validatePathElement(el, fullPath = d.path)
} }

View file

@ -229,8 +229,8 @@ private[akka] trait Children { this: ActorCell ⇒
private def checkName(name: String): String = { private def checkName(name: String): String = {
name match { name match {
case null throw new InvalidActorNameException("actor name must not be null") case null throw InvalidActorNameException("actor name must not be null")
case "" throw new InvalidActorNameException("actor name must not be empty") case "" throw InvalidActorNameException("actor name must not be empty")
case _ case _
ActorPath.validatePathElement(name) ActorPath.validatePathElement(name)
name name

View file

@ -126,7 +126,7 @@ private[akka] object ChildrenContainer {
override def reserve(name: String): ChildrenContainer = override def reserve(name: String): ChildrenContainer =
if (c contains name) if (c contains name)
throw new InvalidActorNameException(s"actor name [$name] is not unique!") throw InvalidActorNameException(s"actor name [$name] is not unique!")
else new NormalChildrenContainer(c.updated(name, ChildNameReserved)) else new NormalChildrenContainer(c.updated(name, ChildNameReserved))
override def unreserve(name: String): ChildrenContainer = c.get(name) match { override def unreserve(name: String): ChildrenContainer = c.get(name) match {
@ -188,7 +188,7 @@ private[akka] object ChildrenContainer {
case Termination throw new IllegalStateException("cannot reserve actor name '" + name + "': terminating") case Termination throw new IllegalStateException("cannot reserve actor name '" + name + "': terminating")
case _ case _
if (c contains name) if (c contains name)
throw new InvalidActorNameException(s"actor name [$name] is not unique!") throw InvalidActorNameException(s"actor name [$name] is not unique!")
else copy(c = c.updated(name, ChildNameReserved)) else copy(c = c.updated(name, ChildNameReserved))
} }

View file

@ -66,7 +66,7 @@ private[akka] trait FaultHandling { this: ActorCell ⇒
// if the actor fails in preRestart, we can do nothing but log it: its best-effort // if the actor fails in preRestart, we can do nothing but log it: its best-effort
if (failedActor.context ne null) failedActor.aroundPreRestart(cause, optionalMessage) if (failedActor.context ne null) failedActor.aroundPreRestart(cause, optionalMessage)
} catch handleNonFatalOrInterruptedException { e } catch handleNonFatalOrInterruptedException { e
val ex = new PreRestartException(self, e, cause, optionalMessage) val ex = PreRestartException(self, e, cause, optionalMessage)
publish(Error(ex, self.path.toString, clazz(failedActor), e.getMessage)) publish(Error(ex, self.path.toString, clazz(failedActor), e.getMessage))
} finally { } finally {
clearActorFields(failedActor, recreate = true) clearActorFields(failedActor, recreate = true)
@ -247,7 +247,7 @@ private[akka] trait FaultHandling { this: ActorCell ⇒
}) })
} catch handleNonFatalOrInterruptedException { e } catch handleNonFatalOrInterruptedException { e
clearActorFields(actor, recreate = false) // in order to prevent preRestart() from happening again clearActorFields(actor, recreate = false) // in order to prevent preRestart() from happening again
handleInvokeFailure(survivors, new PostRestartException(self, e, cause)) handleInvokeFailure(survivors, PostRestartException(self, e, cause))
} }
} }

View file

@ -23,7 +23,7 @@ final case class Envelope private (val message: Any, val sender: ActorRef)
object Envelope { object Envelope {
def apply(message: Any, sender: ActorRef, system: ActorSystem): Envelope = { def apply(message: Any, sender: ActorRef, system: ActorSystem): Envelope = {
if (message == null) throw new InvalidMessageException("Message is null") if (message == null) throw InvalidMessageException("Message is null")
new Envelope(message, if (sender ne Actor.noSender) sender else system.deadLetters) new Envelope(message, if (sender ne Actor.noSender) sender else system.deadLetters)
} }
} }

View file

@ -985,11 +985,11 @@ object Logging {
* <code>akka.stdout-loglevel</code>. * <code>akka.stdout-loglevel</code>.
*/ */
class StandardOutLogger extends MinimalActorRef with StdOutLogger { class StandardOutLogger extends MinimalActorRef with StdOutLogger {
val path: ActorPath = new RootActorPath(Address("akka", "all-systems"), "/StandardOutLogger") val path: ActorPath = RootActorPath(Address("akka", "all-systems"), "/StandardOutLogger")
def provider: ActorRefProvider = throw new UnsupportedOperationException("StandardOutLogger does not provide") def provider: ActorRefProvider = throw new UnsupportedOperationException("StandardOutLogger does not provide")
override val toString = "StandardOutLogger" override val toString = "StandardOutLogger"
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit =
if (message == null) throw new InvalidMessageException("Message is null") if (message == null) throw InvalidMessageException("Message is null")
else print(message) else print(message)
@throws(classOf[java.io.ObjectStreamException]) @throws(classOf[java.io.ObjectStreamException])

View file

@ -530,7 +530,7 @@ private[akka] final class PromiseActorRef private (val provider: ActorRefProvide
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = state match { override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = state match {
case Stopped | _: StoppedWithPath provider.deadLetters ! message case Stopped | _: StoppedWithPath provider.deadLetters ! message
case _ case _
if (message == null) throw new InvalidMessageException("Message is null") if (message == null) throw InvalidMessageException("Message is null")
if (!(result.tryComplete( if (!(result.tryComplete(
message match { message match {
case Status.Success(r) Success(r) case Status.Success(r) Success(r)
@ -592,7 +592,7 @@ private[akka] object PromiseActorRef {
private case object Stopped private case object Stopped
private final case class StoppedWithPath(path: ActorPath) private final case class StoppedWithPath(path: ActorPath)
private val ActorStopResult = Failure(new ActorKilledException("Stopped")) private val ActorStopResult = Failure(ActorKilledException("Stopped"))
def apply(provider: ActorRefProvider, timeout: Timeout, targetName: Any, messageClassName: String, sender: ActorRef = Actor.noSender): PromiseActorRef = { def apply(provider: ActorRefProvider, timeout: Timeout, targetName: Any, messageClassName: String, sender: ActorRef = Actor.noSender): PromiseActorRef = {
val result = Promise[Any]() val result = Promise[Any]()

View file

@ -120,7 +120,7 @@ private[akka] class ClusterReadView(cluster: Cluster) extends Closeable {
/** /**
* Is this node the leader? * Is this node the leader?
*/ */
def isLeader: Boolean = leader == Some(selfAddress) def isLeader: Boolean = leader.contains(selfAddress)
/** /**
* Get the address of the current leader. * Get the address of the current leader.

View file

@ -187,7 +187,7 @@ private[cluster] final case class Gossip(
} }
def isLeader(node: UniqueAddress, selfUniqueAddress: UniqueAddress): Boolean = def isLeader(node: UniqueAddress, selfUniqueAddress: UniqueAddress): Boolean =
leader(selfUniqueAddress) == Some(node) leader(selfUniqueAddress).contains(node)
def leader(selfUniqueAddress: UniqueAddress): Option[UniqueAddress] = def leader(selfUniqueAddress: UniqueAddress): Option[UniqueAddress] =
leaderOf(members, selfUniqueAddress) leaderOf(members, selfUniqueAddress)

View file

@ -142,9 +142,9 @@ class ClusterMessageSerializer(val system: ExtendedActorSystem) extends BaseSeri
// we don't care about races here since it's just a cache // we don't care about races here since it's just a cache
@volatile @volatile
private var protocolCache: String = null private var protocolCache: String = _
@volatile @volatile
private var systemCache: String = null private var systemCache: String = _
private def getProtocol(address: cm.Address): String = { private def getProtocol(address: cm.Address): String = {
val p = address.getProtocol val p = address.getProtocol

View file

@ -559,7 +559,7 @@ private[akka] class RemoteActorRef private[akka] (
} catch handleException(message, Actor.noSender) } catch handleException(message, Actor.noSender)
override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = { override def !(message: Any)(implicit sender: ActorRef = Actor.noSender): Unit = {
if (message == null) throw new InvalidMessageException("Message is null") if (message == null) throw InvalidMessageException("Message is null")
try remote.send(message, OptionVal(sender), this) catch handleException(message, sender) try remote.send(message, OptionVal(sender), this) catch handleException(message, sender)
} }

View file

@ -86,7 +86,7 @@ class TestActorRef[T <: Actor](
*/ */
def underlyingActor: T = { def underlyingActor: T = {
// volatile mailbox read to bring in actor field // volatile mailbox read to bring in actor field
if (isTerminated) throw new IllegalActorStateException("underlying actor is terminated") if (isTerminated) throw IllegalActorStateException("underlying actor is terminated")
underlying.actor.asInstanceOf[T] match { underlying.actor.asInstanceOf[T] match {
case null case null
val t = TestKitExtension(_system).DefaultTimeout val t = TestKitExtension(_system).DefaultTimeout

View file

@ -54,8 +54,8 @@ object TestActor {
} }
final case class RealMessage(msg: AnyRef, sender: ActorRef) extends Message final case class RealMessage(msg: AnyRef, sender: ActorRef) extends Message
case object NullMessage extends Message { case object NullMessage extends Message {
override def msg: AnyRef = throw new IllegalActorStateException("last receive did not dequeue a message") override def msg: AnyRef = throw IllegalActorStateException("last receive did not dequeue a message")
override def sender: ActorRef = throw new IllegalActorStateException("last receive did not dequeue a message") override def sender: ActorRef = throw IllegalActorStateException("last receive did not dequeue a message")
} }
val FALSE = (x: Any) false val FALSE = (x: Any) false

View file

@ -154,7 +154,7 @@ class StubbedActorContext[T](
} }
override def spawn[U](behavior: Behavior[U], name: String, deployment: DeploymentConfig = EmptyDeploymentConfig): ActorRef[U] = override def spawn[U](behavior: Behavior[U], name: String, deployment: DeploymentConfig = EmptyDeploymentConfig): ActorRef[U] =
_children get name match { _children get name match {
case Some(_) throw new untyped.InvalidActorNameException(s"actor name $name is already taken") case Some(_) throw untyped.InvalidActorNameException(s"actor name $name is already taken")
case None case None
// FIXME correct child path for the Inbox ref // FIXME correct child path for the Inbox ref
val i = Inbox[U](name) val i = Inbox[U](name)

View file

@ -101,8 +101,8 @@ private[typed] class ActorCell[T](
protected def ctx: ActorContext[T] = this protected def ctx: ActorContext[T] = this
override def spawn[U](behavior: Behavior[U], name: String, deployment: DeploymentConfig): ActorRef[U] = { override def spawn[U](behavior: Behavior[U], name: String, deployment: DeploymentConfig): ActorRef[U] = {
if (childrenMap contains name) throw new InvalidActorNameException(s"actor name [$name] is not unique") if (childrenMap contains name) throw InvalidActorNameException(s"actor name [$name] is not unique")
if (terminatingMap contains name) throw new InvalidActorNameException(s"actor name [$name] is not yet free") if (terminatingMap contains name) throw InvalidActorNameException(s"actor name [$name] is not yet free")
val dispatcher = deployment.firstOrElse[DispatcherSelector](DispatcherFromExecutionContext(executionContext)) val dispatcher = deployment.firstOrElse[DispatcherSelector](DispatcherFromExecutionContext(executionContext))
val capacity = deployment.firstOrElse(MailboxCapacity(system.settings.DefaultMailboxCapacity)) val capacity = deployment.firstOrElse(MailboxCapacity(system.settings.DefaultMailboxCapacity))
val cell = new ActorCell[U](system, Behavior.validateAsInitial(behavior), system.dispatchers.lookup(dispatcher), capacity.capacity, self) val cell = new ActorCell[U](system, Behavior.validateAsInitial(behavior), system.dispatchers.lookup(dispatcher), capacity.capacity, self)

View file

@ -120,7 +120,7 @@ private[typed] class EventStreamImpl(private val debug: Boolean)(implicit privat
*/ */
private[typed] class StandardOutLogger extends ActorRef[LogEvent](StandardOutLoggerPath) with ActorRefImpl[LogEvent] with StdOutLogger { private[typed] class StandardOutLogger extends ActorRef[LogEvent](StandardOutLoggerPath) with ActorRefImpl[LogEvent] with StdOutLogger {
override def tell(message: LogEvent): Unit = override def tell(message: LogEvent): Unit =
if (message == null) throw new a.InvalidMessageException("Message must not be null") if (message == null) throw a.InvalidMessageException("Message must not be null")
else print(message) else print(message)
def isLocal: Boolean = true def isLocal: Boolean = true