@@ -87,28 +87,37 @@ class AkkaRpcEnvSuite extends RpcEnvSuite {
8787
8888 assert(result.nonEmpty)
8989
90- // Ask with delayed response
90+ // Ask with a delayed response and wait for response immediately that should timeout
91+ fut = sleepyActor.ask(" doh" )(timeout.duration).mapTo[String ]
92+ val msg1 =
93+ intercept[RpcTimeoutException ] {
94+ timeout.awaitResult(fut)
95+ }.getMessage()
96+
97+ assert(msg1.contains(shortProp))
98+
99+ // Ask with delayed response using addMessageIfTimeout in recover callback
91100 fut = sleepyActor.ask(" goodbye" )(timeout.duration).mapTo[String ].
92101 recover(timeout.addMessageIfTimeout)
93102
94103 // Allow future to complete with failure using plain Await.result, this will return
95- // once the future is complete
96- val msg1 =
104+ // once the future is complete to verify addMessageIfTimeout was invoked
105+ val msg2 =
97106 intercept[RpcTimeoutException ] {
98107 Await .result(fut, 200 millis)
99108 }.getMessage()
100109
101- assert(msg1 .contains(shortProp))
110+ assert(msg2 .contains(shortProp))
102111
103112 // Use RpcTimeout.awaitResult to process Future, since it has already failed with
104113 // RpcTimeoutException, the same exception should be thrown
105- val msg2 =
114+ val msg3 =
106115 intercept[RpcTimeoutException ] {
107116 timeout.awaitResult(fut)
108117 }.getMessage()
109118
110119 // Ensure description is not in message twice after addMessageIfTimeout and awaitResult
111- assert(shortProp.r.findAllIn(msg2 ).length === 1 )
120+ assert(shortProp.r.findAllIn(msg3 ).length === 1 )
112121
113122 } finally {
114123 system.shutdown()
0 commit comments