Exception description modified to reflect exclusion of 0 (#19709) timeout. (#20321)

This commit is contained in:
Robert Budźko 2016-04-22 15:42:53 +02:00 committed by Konrad Malawski
parent c57c6eda7e
commit d2eb2b7949
3 changed files with 7 additions and 7 deletions

View file

@ -59,7 +59,7 @@ class AskSpec extends AkkaSpec {
implicit val timeout = Timeout(0 seconds) implicit val timeout = Timeout(0 seconds)
val echo = system.actorOf(Props(new Actor { def receive = { case x sender() ! x } })) val echo = system.actorOf(Props(new Actor { def receive = { case x sender() ! x } }))
val f = echo ? "foo" val f = echo ? "foo"
val expectedMsg = "Timeout length must not be negative, question not sent to [%s]. Sender[null] sent the message of type \"java.lang.String\"." format echo val expectedMsg = "Timeout length must be positive, question not sent to [%s]. Sender[null] sent the message of type \"java.lang.String\"." format echo
intercept[IllegalArgumentException] { intercept[IllegalArgumentException] {
Await.result(f, timeout.duration) Await.result(f, timeout.duration)
}.getMessage should ===(expectedMsg) }.getMessage should ===(expectedMsg)
@ -69,7 +69,7 @@ class AskSpec extends AkkaSpec {
implicit val timeout = Timeout(-1000 seconds) implicit val timeout = Timeout(-1000 seconds)
val echo = system.actorOf(Props(new Actor { def receive = { case x sender() ! x } })) val echo = system.actorOf(Props(new Actor { def receive = { case x sender() ! x } }))
val f = echo ? "foo" val f = echo ? "foo"
val expectedMsg = "Timeout length must not be negative, question not sent to [%s]. Sender[null] sent the message of type \"java.lang.String\"." format echo val expectedMsg = "Timeout length must be positive, question not sent to [%s]. Sender[null] sent the message of type \"java.lang.String\"." format echo
intercept[IllegalArgumentException] { intercept[IllegalArgumentException] {
Await.result(f, timeout.duration) Await.result(f, timeout.duration)
}.getMessage should ===(expectedMsg) }.getMessage should ===(expectedMsg)

View file

@ -289,7 +289,7 @@ final class AskableActorRef(val actorRef: ActorRef) extends AnyVal {
Future.failed[Any](new AskTimeoutException(s"""Recipient[$actorRef] had already been terminated. Sender[$sender] sent the message of type "${message.getClass.getName}".""")) Future.failed[Any](new AskTimeoutException(s"""Recipient[$actorRef] had already been terminated. Sender[$sender] sent the message of type "${message.getClass.getName}"."""))
case ref: InternalActorRef case ref: InternalActorRef
if (timeout.duration.length <= 0) if (timeout.duration.length <= 0)
Future.failed[Any](new IllegalArgumentException(s"""Timeout length must not be negative, question not sent to [$actorRef]. Sender[$sender] sent the message of type "${message.getClass.getName}".""")) Future.failed[Any](new IllegalArgumentException(s"""Timeout length must be positive, question not sent to [$actorRef]. Sender[$sender] sent the message of type "${message.getClass.getName}"."""))
else { else {
val a = PromiseActorRef(ref.provider, timeout, targetName = actorRef, message.getClass.getName, sender) val a = PromiseActorRef(ref.provider, timeout, targetName = actorRef, message.getClass.getName, sender)
actorRef.tell(message, a) actorRef.tell(message, a)
@ -322,7 +322,7 @@ final class ExplicitlyAskableActorRef(val actorRef: ActorRef) extends AnyVal {
case ref: InternalActorRef case ref: InternalActorRef
if (timeout.duration.length <= 0) { if (timeout.duration.length <= 0) {
val message = messageFactory(ref.provider.deadLetters) val message = messageFactory(ref.provider.deadLetters)
Future.failed[Any](new IllegalArgumentException(s"""Timeout length must not be negative, question not sent to [$actorRef]. Sender[$sender] sent the message of type "${message.getClass.getName}".""")) Future.failed[Any](new IllegalArgumentException(s"""Timeout length must be positive, question not sent to [$actorRef]. Sender[$sender] sent the message of type "${message.getClass.getName}"."""))
} else { } else {
val a = PromiseActorRef(ref.provider, timeout, targetName = actorRef, "unknown", sender) val a = PromiseActorRef(ref.provider, timeout, targetName = actorRef, "unknown", sender)
val message = messageFactory(a) val message = messageFactory(a)
@ -382,7 +382,7 @@ final class AskableActorSelection(val actorSel: ActorSelection) extends AnyVal {
case ref: InternalActorRef case ref: InternalActorRef
if (timeout.duration.length <= 0) if (timeout.duration.length <= 0)
Future.failed[Any]( Future.failed[Any](
new IllegalArgumentException(s"""Timeout length must not be negative, question not sent to [$actorSel]. Sender[$sender] sent the message of type "${message.getClass.getName}".""")) new IllegalArgumentException(s"""Timeout length must be positive, question not sent to [$actorSel]. Sender[$sender] sent the message of type "${message.getClass.getName}"."""))
else { else {
val a = PromiseActorRef(ref.provider, timeout, targetName = actorSel, message.getClass.getName, sender) val a = PromiseActorRef(ref.provider, timeout, targetName = actorSel, message.getClass.getName, sender)
actorSel.tell(message, a) actorSel.tell(message, a)
@ -411,7 +411,7 @@ final class ExplicitlyAskableActorSelection(val actorSel: ActorSelection) extend
if (timeout.duration.length <= 0) { if (timeout.duration.length <= 0) {
val message = messageFactory(ref.provider.deadLetters) val message = messageFactory(ref.provider.deadLetters)
Future.failed[Any]( Future.failed[Any](
new IllegalArgumentException(s"""Timeout length must not be negative, question not sent to [$actorSel]. Sender[$sender] sent the message of type "${message.getClass.getName}".""")) new IllegalArgumentException(s"""Timeout length must be positive, question not sent to [$actorSel]. Sender[$sender] sent the message of type "${message.getClass.getName}"."""))
} else { } else {
val a = PromiseActorRef(ref.provider, timeout, targetName = actorSel, "unknown", sender) val a = PromiseActorRef(ref.provider, timeout, targetName = actorSel, "unknown", sender)
val message = messageFactory(a) val message = messageFactory(a)

View file

@ -42,7 +42,7 @@ object AskPattern {
case ref: InternalActorRef case ref: InternalActorRef
if (timeout.duration.length <= 0) if (timeout.duration.length <= 0)
(ActorRef[U](ref.provider.deadLetters), (ActorRef[U](ref.provider.deadLetters),
Future.failed[U](new IllegalArgumentException(s"Timeout length must not be negative, question not sent to [$actorRef]"))) Future.failed[U](new IllegalArgumentException(s"Timeout length must be positive, question not sent to [$actorRef]")))
else { else {
val a = PromiseActorRef(ref.provider, timeout, actorRef, "unknown") val a = PromiseActorRef(ref.provider, timeout, actorRef, "unknown")
val b = ActorRef[U](a) val b = ActorRef[U](a)