From 6a515fe07abc31eeee57eb797a9c9b636c492f3c Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Mon, 14 Mar 2016 11:26:07 +0100 Subject: [PATCH] =htc #20024 introduce more specific exception type for connection close --- .../scala/akka/http/impl/engine/client/PoolSlot.scala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolSlot.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolSlot.scala index d866f04546..833003e8be 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolSlot.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/client/PoolSlot.scala @@ -177,13 +177,13 @@ private object PoolSlot { val results: List[ProcessorOut] = { if (inflightRequests.isEmpty && firstContext.isDefined) { (error match { - case Some(err) ⇒ ResponseDelivery(ResponseContext(firstContext.get, Failure(new RuntimeException("Unexpected (early) disconnect", err)))) - case _ ⇒ ResponseDelivery(ResponseContext(firstContext.get, Failure(new RuntimeException("Unexpected (early) disconnect")))) + case Some(err) ⇒ ResponseDelivery(ResponseContext(firstContext.get, Failure(new UnexpectedDisconnectException("Unexpected (early) disconnect", err)))) + case _ ⇒ ResponseDelivery(ResponseContext(firstContext.get, Failure(new UnexpectedDisconnectException("Unexpected (early) disconnect")))) }) :: Nil } else { inflightRequests.map { rc ⇒ if (rc.retriesLeft == 0) { - val reason = error.fold[Throwable](new RuntimeException("Unexpected disconnect"))(conforms) + val reason = error.fold[Throwable](new UnexpectedDisconnectException("Unexpected disconnect"))(conforms) connInport ! ActorPublisherMessage.Cancel ResponseDelivery(ResponseContext(rc, Failure(reason))) } else SlotEvent.RetryRequest(rc.copy(retriesLeft = rc.retriesLeft - 1)) @@ -237,4 +237,8 @@ private object PoolSlot { context.stop(self) } } + + final class UnexpectedDisconnectException(msg: String, cause: Throwable) extends RuntimeException(msg, cause) { + def this(msg: String) = this(msg, null) + } }