Merge pull request #20025 from ktoso/wip-more-specific-exception-ktoso

=htc #20024 introduce more specific exception type for connection close
This commit is contained in:
Konrad Malawski 2016-03-14 16:33:26 +01:00
commit 5bef3b4de8

View file

@ -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)
}
}