From 92a08ab1d03b5aca1e482adbf27a8b3970e40ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Bud=C5=BAko?= Date: Fri, 6 May 2016 11:01:51 +0200 Subject: [PATCH] htc #20388 HttpServerBluePrint is now resilient to the response being handled before the scheduled timeout response for same exchange. (#20458) --- .../akka/http/impl/engine/server/HttpServerBluePrint.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala index 2f3ff2d5ae..94da06dc8e 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/server/HttpServerBluePrint.scala @@ -276,9 +276,11 @@ private[http] object HttpServerBluePrint { override def onUpstreamFinish() = complete(requestOut) override def onUpstreamFailure(ex: Throwable) = fail(requestOut, ex) def emitTimeoutResponse(response: (TimeoutAccess, HttpResponse)) = - if (openTimeouts.head eq response._1) { + // the application response might has already arrived after we scheduled the timeout response (which is close but ok) + // or current head (same reason) is not for response the timeout has been scheduled for + if (openTimeouts.headOption.exists(_ eq response._1)) { emit(responseOut, response._2, () ⇒ completeStage()) - } // else the application response arrived after we scheduled the timeout response, which is close but ok + } }) // TODO: provide and use default impl for simply connecting an input and an output port as we do here setHandler(requestOut, new OutHandler {