diff --git a/akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala index 5a5a377efc..7ae79fea34 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/ActorSystemSpec.scala @@ -26,6 +26,26 @@ class ActorSystemSpec extends AkkaSpec("""akka.extensions = ["akka.actor.TestExt "An ActorSystem" must { + "reject invalid names" in { + for ( + n ← Seq( + "hallo_welt", + "-hallowelt", + "hallo*welt", + "hallo@welt", + "hallo#welt", + "hallo$welt", + "hallo%welt", + "hallo/welt") + ) intercept[IllegalArgumentException] { + ActorSystem(n) + } + } + + "allow valid names" in { + ActorSystem("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-").shutdown() + } + "support extensions" in { TestExtension(system).system must be === system system.extension(TestExtension).system must be === system diff --git a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala index 2c217a9109..a56e920eb2 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorSystem.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorSystem.scala @@ -416,8 +416,10 @@ abstract class ExtendedActorSystem extends ActorSystem { class ActorSystemImpl protected[akka] (val name: String, applicationConfig: Config, classLoader: ClassLoader) extends ExtendedActorSystem { - if (!name.matches("""^\w+$""")) - throw new IllegalArgumentException("invalid ActorSystem name [" + name + "], must contain only word characters (i.e. [a-zA-Z_0-9])") + if (!name.matches("""^[a-zA-Z0-9][a-zA-Z0-9-]*$""")) + throw new IllegalArgumentException( + "invalid ActorSystem name [" + name + + "], must contain only word characters (i.e. [a-zA-Z_0-9] plus non-leading '-')") import ActorSystem._ diff --git a/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala b/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala index 4475998c4e..ad0ce2108b 100644 --- a/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemoteCommunicationSpec.scala @@ -40,8 +40,8 @@ akka { port = 12345 } actor.deployment { - /blub.remote = "akka://remote_sys@localhost:12346" - /looker/child.remote = "akka://remote_sys@localhost:12346" + /blub.remote = "akka://remote-sys@localhost:12346" + /looker/child.remote = "akka://remote-sys@localhost:12346" /looker/child/grandchild.remote = "akka://RemoteCommunicationSpec@localhost:12345" } } @@ -50,7 +50,7 @@ akka { import RemoteCommunicationSpec._ val conf = ConfigFactory.parseString("akka.remote.netty.port=12346").withFallback(system.settings.config) - val other = ActorSystem("remote_sys", conf) + val other = ActorSystem("remote-sys", conf) val remote = other.actorOf(Props(new Actor { def receive = { @@ -58,7 +58,7 @@ akka { } }), "echo") - val here = system.actorFor("akka://remote_sys@localhost:12346/user/echo") + val here = system.actorFor("akka://remote-sys@localhost:12346/user/echo") override def atTermination() { other.shutdown() @@ -88,13 +88,13 @@ akka { "send dead letters on remote if actor does not exist" in { EventFilter.warning(pattern = "dead.*buh", occurrences = 1).intercept { - system.actorFor("akka://remote_sys@localhost:12346/does/not/exist") ! "buh" + system.actorFor("akka://remote-sys@localhost:12346/does/not/exist") ! "buh" }(other) } "create and supervise children on remote node" in { val r = system.actorOf(Props[Echo], "blub") - r.path.toString must be === "akka://remote_sys@localhost:12346/remote/RemoteCommunicationSpec@localhost:12345/user/blub" + r.path.toString must be === "akka://remote-sys@localhost:12346/remote/RemoteCommunicationSpec@localhost:12345/user/blub" r ! 42 expectMsg(42) EventFilter[Exception]("crash", occurrences = 1).intercept { diff --git a/akka-remote/src/test/scala/akka/remote/RemoteRouterSpec.scala b/akka-remote/src/test/scala/akka/remote/RemoteRouterSpec.scala index 4b090a0e79..1255489691 100644 --- a/akka-remote/src/test/scala/akka/remote/RemoteRouterSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/RemoteRouterSpec.scala @@ -28,7 +28,7 @@ akka { /blub { router = round-robin nr-of-instances = 2 - target.nodes = ["akka://remote_sys@localhost:12347"] + target.nodes = ["akka://remote-sys@localhost:12347"] } /elastic-blub { router = round-robin @@ -36,10 +36,10 @@ akka { lower-bound = 2 upper-bound = 3 } - target.nodes = ["akka://remote_sys@localhost:12347"] + target.nodes = ["akka://remote-sys@localhost:12347"] } /remote-blub { - remote = "akka://remote_sys@localhost:12347" + remote = "akka://remote-sys@localhost:12347" router = round-robin nr-of-instances = 2 } @@ -47,12 +47,12 @@ akka { remote = "akka://RemoteRouterSpec" router = round-robin nr-of-instances = 2 - target.nodes = ["akka://remote_sys@localhost:12347"] + target.nodes = ["akka://remote-sys@localhost:12347"] } /local-blub2 { router = round-robin nr-of-instances = 4 - target.nodes = ["akka://remote_sys@localhost:12347"] + target.nodes = ["akka://remote-sys@localhost:12347"] } } } @@ -67,7 +67,7 @@ akka.actor.deployment { nr-of-instances = 4 } }""").withFallback(system.settings.config) - val other = ActorSystem("remote_sys", conf) + val other = ActorSystem("remote-sys", conf) override def atTermination() { other.shutdown() @@ -84,13 +84,13 @@ akka.actor.deployment { val children = replies.toSet children must have size 2 children.map(_.parent) must have size 1 - children foreach (_.address.toString must be === "akka://remote_sys@localhost:12347") + children foreach (_.address.toString must be === "akka://remote-sys@localhost:12347") system.stop(router) } "deploy its children on remote host driven by programatic definition" in { val router = system.actorOf(Props[Echo].withRouter(new RemoteRouterConfig(RoundRobinRouter(2), - Seq(Address("akka", "remote_sys", "localhost", 12347)))), "blub2") + Seq(Address("akka", "remote-sys", "localhost", 12347)))), "blub2") val replies = for (i ← 1 to 5) yield { router ! "" expectMsgType[ActorRef].path @@ -98,7 +98,7 @@ akka.actor.deployment { val children = replies.toSet children must have size 2 children.map(_.parent) must have size 1 - children foreach (_.address.toString must be === "akka://remote_sys@localhost:12347") + children foreach (_.address.toString must be === "akka://remote-sys@localhost:12347") system.stop(router) } @@ -111,13 +111,13 @@ akka.actor.deployment { val children = replies.toSet children.size must be >= 2 children.map(_.parent) must have size 1 - children foreach (_.address.toString must be === "akka://remote_sys@localhost:12347") + children foreach (_.address.toString must be === "akka://remote-sys@localhost:12347") system.stop(router) } "deploy remote routers based on configuration" in { val router = system.actorOf(Props[Echo].withRouter(FromConfig), "remote-blub") - router.path.address.toString must be("akka://remote_sys@localhost:12347") + router.path.address.toString must be("akka://remote-sys@localhost:12347") val replies = for (i ← 1 to 5) yield { router ! "" expectMsgType[ActorRef].path @@ -127,14 +127,14 @@ akka.actor.deployment { val parents = children.map(_.parent) parents must have size 1 parents.head must be(router.path) - children foreach (_.address.toString must be === "akka://remote_sys@localhost:12347") + children foreach (_.address.toString must be === "akka://remote-sys@localhost:12347") system.stop(router) } "deploy remote routers based on explicit deployment" in { val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2)) - .withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote_sys@localhost:12347")))), "remote-blub2") - router.path.address.toString must be("akka://remote_sys@localhost:12347") + .withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote-sys@localhost:12347")))), "remote-blub2") + router.path.address.toString must be("akka://remote-sys@localhost:12347") val replies = for (i ← 1 to 5) yield { router ! "" expectMsgType[ActorRef].path @@ -144,13 +144,13 @@ akka.actor.deployment { val parents = children.map(_.parent) parents must have size 1 parents.head must be(router.path) - children foreach (_.address.toString must be === "akka://remote_sys@localhost:12347") + children foreach (_.address.toString must be === "akka://remote-sys@localhost:12347") system.stop(router) } "let remote deployment be overridden by local configuration" in { val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2)) - .withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote_sys@localhost:12347")))), "local-blub") + .withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote-sys@localhost:12347")))), "local-blub") router.path.address.toString must be("akka://RemoteRouterSpec") val replies = for (i ← 1 to 5) yield { router ! "" @@ -160,15 +160,15 @@ akka.actor.deployment { children must have size 2 val parents = children.map(_.parent) parents must have size 1 - parents.head.address must be(Address("akka", "remote_sys", "localhost", 12347)) - children foreach (_.address.toString must be === "akka://remote_sys@localhost:12347") + parents.head.address must be(Address("akka", "remote-sys", "localhost", 12347)) + children foreach (_.address.toString must be === "akka://remote-sys@localhost:12347") system.stop(router) } "let remote deployment router be overridden by local configuration" in { val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2)) - .withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote_sys@localhost:12347")))), "local-blub2") - router.path.address.toString must be("akka://remote_sys@localhost:12347") + .withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote-sys@localhost:12347")))), "local-blub2") + router.path.address.toString must be("akka://remote-sys@localhost:12347") val replies = for (i ← 1 to 5) yield { router ! "" expectMsgType[ActorRef].path @@ -178,14 +178,14 @@ akka.actor.deployment { val parents = children.map(_.parent) parents must have size 1 parents.head must be(router.path) - children foreach (_.address.toString must be === "akka://remote_sys@localhost:12347") + children foreach (_.address.toString must be === "akka://remote-sys@localhost:12347") system.stop(router) } "let remote deployment be overridden by remote configuration" in { val router = system.actorOf(Props[Echo].withRouter(RoundRobinRouter(2)) - .withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote_sys@localhost:12347")))), "remote-override") - router.path.address.toString must be("akka://remote_sys@localhost:12347") + .withDeploy(Deploy(scope = RemoteScope(AddressFromURIString("akka://remote-sys@localhost:12347")))), "remote-override") + router.path.address.toString must be("akka://remote-sys@localhost:12347") val replies = for (i ← 1 to 5) yield { router ! "" expectMsgType[ActorRef].path @@ -195,7 +195,7 @@ akka.actor.deployment { val parents = children.map(_.parent) parents must have size 1 parents.head must be(router.path) - children foreach (_.address.toString must be === "akka://remote_sys@localhost:12347") + children foreach (_.address.toString must be === "akka://remote-sys@localhost:12347") system.stop(router) }