diff --git a/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala index bf2a50c90c..72456761ef 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala @@ -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 { diff --git a/akka-actor/src/main/scala/akka/actor/ActorCell.scala b/akka-actor/src/main/scala/akka/actor/ActorCell.scala index 05c33fe0ca..b34f5f1d43 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorCell.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorCell.scala @@ -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 there’s nothing we can do diff --git a/akka-actor/src/main/scala/akka/actor/ActorPath.scala b/akka-actor/src/main/scala/akka/actor/ActorPath.scala index 515a0ea54c..632c6b5f5c 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorPath.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorPath.scala @@ -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 `$`, """ + diff --git a/akka-actor/src/main/scala/akka/actor/ActorRef.scala b/akka-actor/src/main/scala/akka/actor/ActorRef.scala index 21ac2c9b7a..c0adcb367e 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRef.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRef.scala @@ -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)) diff --git a/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala b/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala index ffbec3acc1..a29c18944b 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRefProvider.scala @@ -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]") } diff --git a/akka-actor/src/main/scala/akka/actor/Deployer.scala b/akka-actor/src/main/scala/akka/actor/Deployer.scala index 72cd1cb7d5..1c58dc8fc7 100644 --- a/akka-actor/src/main/scala/akka/actor/Deployer.scala +++ b/akka-actor/src/main/scala/akka/actor/Deployer.scala @@ -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) } diff --git a/akka-actor/src/main/scala/akka/actor/dungeon/Children.scala b/akka-actor/src/main/scala/akka/actor/dungeon/Children.scala index 9e84c4cef5..4cdc142525 100644 --- a/akka-actor/src/main/scala/akka/actor/dungeon/Children.scala +++ b/akka-actor/src/main/scala/akka/actor/dungeon/Children.scala @@ -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 diff --git a/akka-actor/src/main/scala/akka/actor/dungeon/ChildrenContainer.scala b/akka-actor/src/main/scala/akka/actor/dungeon/ChildrenContainer.scala index 9b8d42484a..62a6e8dd93 100644 --- a/akka-actor/src/main/scala/akka/actor/dungeon/ChildrenContainer.scala +++ b/akka-actor/src/main/scala/akka/actor/dungeon/ChildrenContainer.scala @@ -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)) } diff --git a/akka-actor/src/main/scala/akka/actor/dungeon/FaultHandling.scala b/akka-actor/src/main/scala/akka/actor/dungeon/FaultHandling.scala index 3ef6740f6e..bf05cf6a79 100644 --- a/akka-actor/src/main/scala/akka/actor/dungeon/FaultHandling.scala +++ b/akka-actor/src/main/scala/akka/actor/dungeon/FaultHandling.scala @@ -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) @@ -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)) } } diff --git a/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala index 73e082ee5b..45d6c721b9 100644 --- a/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/AbstractDispatcher.scala @@ -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) } } diff --git a/akka-actor/src/main/scala/akka/event/Logging.scala b/akka-actor/src/main/scala/akka/event/Logging.scala index 5072dd86fb..498882da6b 100644 --- a/akka-actor/src/main/scala/akka/event/Logging.scala +++ b/akka-actor/src/main/scala/akka/event/Logging.scala @@ -985,11 +985,11 @@ object Logging { * akka.stdout-loglevel. */ 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]) diff --git a/akka-actor/src/main/scala/akka/pattern/AskSupport.scala b/akka-actor/src/main/scala/akka/pattern/AskSupport.scala index 85dd8ff861..b3772dd43e 100644 --- a/akka-actor/src/main/scala/akka/pattern/AskSupport.scala +++ b/akka-actor/src/main/scala/akka/pattern/AskSupport.scala @@ -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]() diff --git a/akka-cluster/src/main/scala/akka/cluster/ClusterReadView.scala b/akka-cluster/src/main/scala/akka/cluster/ClusterReadView.scala index 8f5d612e0d..d446f6c768 100644 --- a/akka-cluster/src/main/scala/akka/cluster/ClusterReadView.scala +++ b/akka-cluster/src/main/scala/akka/cluster/ClusterReadView.scala @@ -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. diff --git a/akka-cluster/src/main/scala/akka/cluster/Gossip.scala b/akka-cluster/src/main/scala/akka/cluster/Gossip.scala index 745d6d2440..fee83bb317 100644 --- a/akka-cluster/src/main/scala/akka/cluster/Gossip.scala +++ b/akka-cluster/src/main/scala/akka/cluster/Gossip.scala @@ -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) diff --git a/akka-cluster/src/main/scala/akka/cluster/protobuf/ClusterMessageSerializer.scala b/akka-cluster/src/main/scala/akka/cluster/protobuf/ClusterMessageSerializer.scala index 29c3174610..94416c2451 100644 --- a/akka-cluster/src/main/scala/akka/cluster/protobuf/ClusterMessageSerializer.scala +++ b/akka-cluster/src/main/scala/akka/cluster/protobuf/ClusterMessageSerializer.scala @@ -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 diff --git a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala index 68d7400eb6..14658835f7 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala @@ -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) } diff --git a/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala b/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala index 0976ed6b09..5340e3f7fd 100644 --- a/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala +++ b/akka-testkit/src/main/scala/akka/testkit/TestActorRef.scala @@ -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 diff --git a/akka-testkit/src/main/scala/akka/testkit/TestKit.scala b/akka-testkit/src/main/scala/akka/testkit/TestKit.scala index a42e457fcf..b27e23a2ab 100644 --- a/akka-testkit/src/main/scala/akka/testkit/TestKit.scala +++ b/akka-testkit/src/main/scala/akka/testkit/TestKit.scala @@ -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 diff --git a/akka-typed/src/main/scala/akka/typed/ActorContext.scala b/akka-typed/src/main/scala/akka/typed/ActorContext.scala index ff35e6c2e0..72082f0707 100644 --- a/akka-typed/src/main/scala/akka/typed/ActorContext.scala +++ b/akka-typed/src/main/scala/akka/typed/ActorContext.scala @@ -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) diff --git a/akka-typed/src/main/scala/akka/typed/internal/ActorCell.scala b/akka-typed/src/main/scala/akka/typed/internal/ActorCell.scala index 5c18ce6b3e..9ae334dfef 100644 --- a/akka-typed/src/main/scala/akka/typed/internal/ActorCell.scala +++ b/akka-typed/src/main/scala/akka/typed/internal/ActorCell.scala @@ -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) diff --git a/akka-typed/src/main/scala/akka/typed/internal/EventStreamImpl.scala b/akka-typed/src/main/scala/akka/typed/internal/EventStreamImpl.scala index 6fc5785cb2..8f700ca126 100644 --- a/akka-typed/src/main/scala/akka/typed/internal/EventStreamImpl.scala +++ b/akka-typed/src/main/scala/akka/typed/internal/EventStreamImpl.scala @@ -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