Don't decode path in RelativeActorPath, see #2603

This commit is contained in:
Patrik Nordwall 2012-10-05 13:53:35 +02:00
parent 89c1f66b1f
commit 5c0e4672fd
3 changed files with 47 additions and 3 deletions

View file

@ -39,6 +39,21 @@ class LocalActorRefProviderSpec extends AkkaSpec(LocalActorRefProviderSpec.confi
a must be === b
}
"find child actor with URL encoded name using actorFor" in {
val childName = "akka%3A%2F%2FClusterSystem%40127.0.0.1%3A2552"
val a = system.actorOf(Props(new Actor {
val child = context.actorOf(Props.empty, name = childName)
assert(childName == child.path.name)
def receive = {
case "lookup" sender ! context.actorFor(childName)
}
}))
a.tell("lookup", testActor)
val b = expectMsgType[ActorRef]
b.isTerminated must be(false)
b.path.name must be(childName)
}
}
"An ActorRefFactory" must {

View file

@ -0,0 +1,29 @@
/**
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.actor
import org.scalatest.WordSpec
import org.scalatest.matchers.MustMatchers
import java.net.URLEncoder
class RelativeActorPathSpec extends WordSpec with MustMatchers {
def elements(path: String): Seq[String] = path match {
case RelativeActorPath(elem) elem.toSeq
case _ Nil
}
"RelativeActorPath" must {
"match single name" in {
elements("foo") must be(Seq("foo"))
}
"match path separated names" in {
elements("foo/bar/baz") must be(Seq("foo", "bar", "baz"))
}
"match url encoded name" in {
val name = URLEncoder.encode("akka://ClusterSystem@127.0.0.1:2552", "UTF-8")
elements(name) must be(Seq(name))
}
}
}

View file

@ -75,7 +75,7 @@ object RelativeActorPath extends PathUtils {
try {
val uri = new URI(addr)
if (uri.isAbsolute) None
else Some(split(uri.getPath))
else Some(split(uri.getRawPath))
} catch {
case _: URISyntaxException None
}
@ -122,10 +122,10 @@ object ActorPathExtractor extends PathUtils {
def unapply(addr: String): Option[(Address, Iterable[String])] =
try {
val uri = new URI(addr)
if (uri.getPath == null) None
if (uri.getRawPath == null) None
else AddressFromURIString.unapply(uri) match {
case None None
case Some(addr) Some((addr, split(uri.getPath).drop(1)))
case Some(addr) Some((addr, split(uri.getRawPath).drop(1)))
}
} catch {
case _: URISyntaxException None