Skip to content

Commit

Permalink
Merge pull request #22138 from VEINHORN/master
Browse files Browse the repository at this point in the history
Remove unnecessary new keywords
  • Loading branch information
patriknw committed Jan 17, 2017
2 parents c61ed5a + 0eac4d4 commit 6c8a691
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 34 deletions.
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions akka-actor/src/main/scala/akka/actor/ActorCell.scala
Expand Up @@ -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

Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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 there’s nothing we can do
Expand Down
4 changes: 2 additions & 2 deletions akka-actor/src/main/scala/akka/actor/ActorPath.scala
Expand Up @@ -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 `$`, """ +
Expand Down
4 changes: 2 additions & 2 deletions akka-actor/src/main/scala/akka/actor/ActorRef.scala
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
Expand Up @@ -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]")
}

Expand Down
2 changes: 1 addition & 1 deletion akka-actor/src/main/scala/akka/actor/Deployer.scala
Expand Up @@ -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)
}

Expand Down
4 changes: 2 additions & 2 deletions akka-actor/src/main/scala/akka/actor/dungeon/Children.scala
Expand Up @@ -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
Expand Down
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))
}

Expand Down
Expand Up @@ -66,7 +66,7 @@ private[akka] trait FaultHandling { this: ActorCell ⇒
// if the actor fails in preRestart, we can do nothing but log it: it’s 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)
Expand Down Expand Up @@ -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))
}
}

Expand Down
Expand Up @@ -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)
}
}
Expand Down
4 changes: 2 additions & 2 deletions akka-actor/src/main/scala/akka/event/Logging.scala
Expand Up @@ -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])
Expand Down
4 changes: 2 additions & 2 deletions akka-actor/src/main/scala/akka/pattern/AskSupport.scala
Expand Up @@ -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)
Expand Down Expand Up @@ -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]()
Expand Down
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion akka-cluster/src/main/scala/akka/cluster/Gossip.scala
Expand Up @@ -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)
Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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)
}

Expand Down
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions akka-testkit/src/main/scala/akka/testkit/TestKit.scala
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion akka-typed/src/main/scala/akka/typed/ActorContext.scala
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions akka-typed/src/main/scala/akka/typed/internal/ActorCell.scala
Expand Up @@ -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)
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit 6c8a691

Please sign in to comment.