From 4c2eb74c78b1338d92149e43868a187dc0922bf8 Mon Sep 17 00:00:00 2001 From: Gaetan Hervouet Date: Wed, 18 Dec 2013 17:30:19 -0500 Subject: [PATCH] =act #3800: Add timeout value in AskTimeoutException message. --- .../src/test/scala/akka/pattern/AskSpec.scala | 8 ++++++++ akka-actor/src/main/scala/akka/pattern/AskSupport.scala | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/akka-actor-tests/src/test/scala/akka/pattern/AskSpec.scala b/akka-actor-tests/src/test/scala/akka/pattern/AskSpec.scala index 1d8b880f09..ad73024623 100644 --- a/akka-actor-tests/src/test/scala/akka/pattern/AskSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/pattern/AskSpec.scala @@ -76,6 +76,14 @@ class AskSpec extends AkkaSpec { }.getMessage.contains("/user/silent") should be(true) } + "include timeout information in AskTimeout" in { + implicit val timeout = Timeout(0.5 seconds) + val f = system.actorOf(Props.empty) ? "noreply" + intercept[AskTimeoutException] { + Await.result(f, remaining) + }.getMessage should include(timeout.duration.toMillis.toString) + } + "work for ActorSelection" in { implicit val timeout = Timeout(5 seconds) import system.dispatcher diff --git a/akka-actor/src/main/scala/akka/pattern/AskSupport.scala b/akka-actor/src/main/scala/akka/pattern/AskSupport.scala index afebca95c7..8eb63c3785 100644 --- a/akka-actor/src/main/scala/akka/pattern/AskSupport.scala +++ b/akka-actor/src/main/scala/akka/pattern/AskSupport.scala @@ -330,7 +330,7 @@ private[akka] object PromiseActorRef { val a = new PromiseActorRef(provider, result) implicit val ec = a.internalCallingThreadExecutionContext val f = scheduler.scheduleOnce(timeout.duration) { - result tryComplete Failure(new AskTimeoutException(s"Ask timed out on [$targetName]")) + result tryComplete Failure(new AskTimeoutException(s"Ask timed out on [$targetName] after [${timeout.duration.toMillis} ms]")) } result.future onComplete { _ ⇒ try a.stop() finally f.cancel() } a