=str #22917 recoverWithRetries allow 0 and negative values
This commit is contained in:
parent
ee79a3d1a8
commit
b7d7316c1c
9 changed files with 51 additions and 16 deletions
|
|
@ -1768,12 +1768,9 @@ private[stream] object Collect {
|
|||
/**
|
||||
* INTERNAL API
|
||||
*/
|
||||
@InternalApi private[stream] object RecoverWith {
|
||||
val InfiniteRetries = -1
|
||||
}
|
||||
@InternalApi private[stream] object RecoverWith
|
||||
|
||||
@InternalApi private[akka] final class RecoverWith[T, M](val maximumRetries: Int, val pf: PartialFunction[Throwable, Graph[SourceShape[T], M]]) extends SimpleLinearGraphStage[T] {
|
||||
require(maximumRetries >= -1, "number of retries must be non-negative or equal to -1")
|
||||
|
||||
override def initialAttributes = DefaultAttributes.recoverWith
|
||||
|
||||
|
|
@ -1791,7 +1788,7 @@ private[stream] object Collect {
|
|||
})
|
||||
|
||||
def onFailure(ex: Throwable) =
|
||||
if ((maximumRetries == RecoverWith.InfiniteRetries || attempt < maximumRetries) && pf.isDefinedAt(ex)) {
|
||||
if ((maximumRetries < 0 || attempt < maximumRetries) && pf.isDefinedAt(ex)) {
|
||||
switchTo(pf(ex))
|
||||
attempt += 1
|
||||
} else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue