=htc #20024 introduce more specific exception type for connection close

This commit is contained in:
Konrad Malawski 2016-03-14 11:26:07 +01:00
parent ed8ba7873c
commit 6a515fe07a

View file

@ -177,13 +177,13 @@ private object PoolSlot {
val results: List[ProcessorOut] = { val results: List[ProcessorOut] = {
if (inflightRequests.isEmpty && firstContext.isDefined) { if (inflightRequests.isEmpty && firstContext.isDefined) {
(error match { (error match {
case Some(err) ResponseDelivery(ResponseContext(firstContext.get, Failure(new RuntimeException("Unexpected (early) disconnect", err)))) case Some(err) ResponseDelivery(ResponseContext(firstContext.get, Failure(new UnexpectedDisconnectException("Unexpected (early) disconnect", err))))
case _ ResponseDelivery(ResponseContext(firstContext.get, Failure(new RuntimeException("Unexpected (early) disconnect")))) case _ ResponseDelivery(ResponseContext(firstContext.get, Failure(new UnexpectedDisconnectException("Unexpected (early) disconnect"))))
}) :: Nil }) :: Nil
} else { } else {
inflightRequests.map { rc inflightRequests.map { rc
if (rc.retriesLeft == 0) { 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 connInport ! ActorPublisherMessage.Cancel
ResponseDelivery(ResponseContext(rc, Failure(reason))) ResponseDelivery(ResponseContext(rc, Failure(reason)))
} else SlotEvent.RetryRequest(rc.copy(retriesLeft = rc.retriesLeft - 1)) } else SlotEvent.RetryRequest(rc.copy(retriesLeft = rc.retriesLeft - 1))
@ -237,4 +237,8 @@ private object PoolSlot {
context.stop(self) context.stop(self)
} }
} }
final class UnexpectedDisconnectException(msg: String, cause: Throwable) extends RuntimeException(msg, cause) {
def this(msg: String) = this(msg, null)
}
} }