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 = _
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) {
throw new ActorKilledException("I said I wanted to DIE, dammit!")
throw ActorKilledException("I said I wanted to DIE, dammit!")
}
override def postStop {

View file

@ -340,7 +340,7 @@ private[akka] object ActorCell {
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
@ -510,7 +510,7 @@ private[akka] class ActorCell(
msg.message match {
case t: Terminated receivedTerminated(t)
case AddressTerminated(address) addressTerminated(address)
case Kill throw new ActorKilledException("Kill")
case Kill throw ActorKilledException("Kill")
case PoisonPill self.stop()
case sel: ActorSelectionMessage receiveSelection(sel)
case Identify(messageId) sender() ! ActorIdentity(messageId, Some(self))
@ -642,7 +642,7 @@ private[akka] class ActorCell(
if (actorInstance ne null) {
if (!Reflect.lookupAndSetField(actorInstance.getClass, actorInstance, "context", context)
|| !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

View file

@ -88,9 +88,9 @@ object ActorPath {
case ValidPathCode
// valid
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
throw new InvalidActorNameException(
throw InvalidActorNameException(
s"""Invalid actor path element [$element]$fullPathMsg, illegal character [${element(invalidAt)}] at position: $invalidAt. """ +
"""Actor paths MUST: """ +
"""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 {
case null throw new InvalidMessageException("Message is null")
case null throw InvalidMessageException("Message is null")
case d: DeadLetter
specialHandle(d.message, d.sender) // do NOT form endless loops, since deadLetters will resend!
case _ if !specialHandle(message, sender)
@ -579,7 +579,7 @@ private[akka] class DeadLetterActorRef(
_eventStream: EventStream) extends EmptyLocalActorRef(_provider, _path, _eventStream) {
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 d: DeadLetter if (!specialHandle(d.message, d.sender)) eventStream.publish(d)
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 =
if (isWalking)
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]")
}

View file

@ -153,7 +153,7 @@ private[akka] class Deployer(val settings: ActorSystem.Settings, val dynamicAcce
def deploy(d: Deploy): Unit = {
@tailrec def add(path: Array[String], d: Deploy, w: WildcardIndex[Deploy] = deployments.get): Unit = {
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)
}

View file

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

View file

@ -126,7 +126,7 @@ private[akka] object ChildrenContainer {
override def reserve(name: String): ChildrenContainer =
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))
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 _
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))
}

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 (failedActor.context ne null) failedActor.aroundPreRestart(cause, optionalMessage)
} 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))
} finally {
clearActorFields(failedActor, recreate = true)
@ -247,7 +247,7 @@ private[akka] trait FaultHandling { this: ActorCell ⇒
})
} catch handleNonFatalOrInterruptedException { e
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 {
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)
}
}

View file

@ -985,11 +985,11 @@ object Logging {
* <code>akka.stdout-loglevel</code>.
*/
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")
override val toString = "StandardOutLogger"
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)
@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 {
case Stopped | _: StoppedWithPath provider.deadLetters ! message
case _
if (message == null) throw new InvalidMessageException("Message is null")
if (message == null) throw InvalidMessageException("Message is null")
if (!(result.tryComplete(
message match {
case Status.Success(r) Success(r)
@ -592,7 +592,7 @@ private[akka] object PromiseActorRef {
private case object Stopped
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 = {
val result = Promise[Any]()

View file

@ -120,7 +120,7 @@ private[akka] class ClusterReadView(cluster: Cluster) extends Closeable {
/**
* Is this node the leader?
*/
def isLeader: Boolean = leader == Some(selfAddress)
def isLeader: Boolean = leader.contains(selfAddress)
/**
* 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 =
leader(selfUniqueAddress) == Some(node)
leader(selfUniqueAddress).contains(node)
def leader(selfUniqueAddress: UniqueAddress): Option[UniqueAddress] =
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
@volatile
private var protocolCache: String = null
private var protocolCache: String = _
@volatile
private var systemCache: String = null
private var systemCache: String = _
private def getProtocol(address: cm.Address): String = {
val p = address.getProtocol

View file

@ -559,7 +559,7 @@ private[akka] class RemoteActorRef private[akka] (
} catch handleException(message, Actor.noSender)
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)
}

View file

@ -86,7 +86,7 @@ class TestActorRef[T <: Actor](
*/
def underlyingActor: T = {
// 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 {
case null
val t = TestKitExtension(_system).DefaultTimeout

View file

@ -54,8 +54,8 @@ object TestActor {
}
final case class RealMessage(msg: AnyRef, sender: ActorRef) extends Message
case object NullMessage extends Message {
override def msg: AnyRef = throw new IllegalActorStateException("last receive did not dequeue a message")
override def sender: ActorRef = 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 IllegalActorStateException("last receive did not dequeue a message")
}
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] =
_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
// FIXME correct child path for the Inbox ref
val i = Inbox[U](name)

View file

@ -101,8 +101,8 @@ private[typed] class ActorCell[T](
protected def ctx: ActorContext[T] = this
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 (terminatingMap contains name) throw new InvalidActorNameException(s"actor name [$name] is not yet free")
if (childrenMap contains name) throw InvalidActorNameException(s"actor name [$name] is not unique")
if (terminatingMap contains name) throw InvalidActorNameException(s"actor name [$name] is not yet free")
val dispatcher = deployment.firstOrElse[DispatcherSelector](DispatcherFromExecutionContext(executionContext))
val capacity = deployment.firstOrElse(MailboxCapacity(system.settings.DefaultMailboxCapacity))
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 {
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)
def isLocal: Boolean = true